Tuesday, May 25, 2010

Show next day from a date value in PHP



$date = date("Y-m-d");

echo date('Y-m-d',strtotime("+1 day",strtotime($date)));

Calculate Difference between two dates in PHP

This is an post on how to calculate difference between two dates. A good read:


Calculating date difference more precisely in PHP




Otherwise you can find difference between two dates like this:

$date1 = "2010-03-12";
$date2 = "2010-03-20";

$ts1 = strtotime($date1);
$ts2 = strtotime($date2);

$diff = (int)$ts2-(int)$ts1;
$diff = round($diff/86400);

echo 'The difference between '.$date2.' and '.$date1.' is '.$diff;

?>