How can we know the number of days between two given dates
using PHP?
How can we know the number of days between two given dates
using MySQL?

Answer Posted / indira majumder

<?php
$date1 = date('y-m-d');
$date2 = '2007-12-7';
$days = (strtotime($date2)-strtotime($date1))/(60*60*24);
echo "Number of Days since '2007-12-7': $days";

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is polymorphism?

2069


What is the difference between fopen() and fclose()?

589


Can we use session in mvc?

560


What is encapsulation in oop php?

521


What does it mean when it says the csrf token is invalid?

498






What are examples of independent and dependent variables?

495


What are the Advantages and Application Areas of PHP?

515


What is the correct line to use within the php.ini file, to specify that 128mb would be the maximum amount of memory that a script may use?

574


Tell me whether it is possible to share a single instance of a memcache between multiple php projects?

541


how retrive the video file in php using video tag

1380


How to remove the new line character from the end of a text line?

518


/temp is a type of filesystem directory. State Whether True or False?

592


Is php a dying language?

539


Tell me which function gives us the number of affected entries by a query?

525


What is difference Between PHP 5 and 7?

521