Monday, November 23, 2009

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

This is how we calculate the number of days between two given dates using PHP:

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

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off