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

Posted on    September-17-2011 1:24 AM

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

Chris Anderson
Chris Anderson

Total Post:197

Points:985
Posted on    September-17-2011 12:00 AM

Simple arithmetic:

$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