Date difference in Days in PHP

Posted By: Matpal - December 16, 2011
Date difference in Days in PHP. Input two days and returns difference in days.



<?php

$time1="2012-12-19";
$time2="2011-12-16";

echo dayDiff($time1,$time2);

function dayDiff($time1,$time2)
{
$d1=strtotime($time1);
$d2=strtotime($time2);


return round(abs($d1 - $d2) / 60,2)/(24*60);

}

?>

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.