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 / abdulgafoor

Using PHP

$date1 = date("Y-m-d");
$date2= "2005-5-15";
$nodays = (strtotime()-strtotime())/(60*60*24);

echo "no of days are $nodays ";

Using mySql :

mysql>SELECT DATEDIFF(NOW(),'2005-5-15');
The output will give you the exact number of days.

Is This Answer Correct ?    12 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain me what is the use of header() function in php?

623


Define metaphone()?

8303


How can you retrieve a cookie value?

549


What does nan stand for computer science?

508


Explain about getters and setters in php?

535






How to make database connection in php?

541


Tell me what is use of in_array() function in php?

575


Can we extend two classes in php?

531


Is variable name casesensitive in php?

554


Can we learn php without html?

552


What is the difference between $name and $$name?

529


How to create a table using php?

544


What is the difference between get & post ?

543


How to access standard error stream in PHP?

589


Why die is used in php?

564