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

Can php variables have numbers?

519


What is the difference between require_once and require in php?

547


What is the use of ajax in php?

498


What is user defined function in php?

524


What is the purpose of constant() function?

509






What is the difference between require and include in php?

500


Is php a framework?

513


What is full form of PHP?

601


What is the use of pear in php?

548


Which function gives us the number of affected entries by a query?

505


Which function would you use to merge two arrays in php?

564


How to write the form tag correctly for uploading files?

549


What is memcache?

532


Is set in php?

539


Is jquery better than javascript?

550