Home > DeveloperSection > Interviews > How can we know the number of days between two given dates using PHP?

Posted on    June-13-2011 4:32 AM

 PHP PHP 
Ratings:
 1 Answer(s)
  1004  View(s)
Rate this:

Awadhendra Tiwari

Total Post:510

Points:2550
Posted on    June-13-2011 12:00 AM

We will use following concept to retrive difference between two dates.

$date1 = date('Y-m-d');
$date2 = '2006-07-01';
$days = (strtotime() - strtotime()) / (60 * 60 * 24);
echo "Number of days since '2006-07-01': $days";


Don't want to miss updates? Please click the below button!

Follow MindStick