When we develop, we often encounter to add a time to another time minus is it, I would like to recommend two PHP date difference days processing function.
First type:
<?php
function count_days ($a, $b) {
$a _dt=getdate ($a);
$b _dt=getdate ($b);
$a _new=mktime (12,0,0, $a _dt[' mon '), $a _dt[' mday '], $a _dt[' year ']);
$b _new=mktime (12,0,0, $b _dt[' mon '), $b _dt[' Mday '], $b _dt[' year ']);
Return round (ABS ($a _new-$b _new)/86400);
}
Today and October 11, 2008 How many days difference
$date 1=strtotime (Time ());
$date 1=strtotime (' 10/11/2008 ');
$result =count_days ($date 1, $date 2);
echo $result;
?>
The second type:
<?php
Today and September 9, 2008 How many days difference
$Date _1=date ("y-m-d");
$Date _2= "2008-10-11";
$d 1=strtotime ($Date _1);
$d 2=strtotime ($Date _2);
$Days =round (($d 2-$d 1)/3600/24);
echo "Today differs from October 11, 2008". $Days. " Days ";
?>