public
Created

PHP Date difference in Days

  • Download Gist
file.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php
function dateDiff($start, $end) {
 
$start_ts = strtotime($start);
$end_ts = strtotime($end);
$diff = $end_ts - $start_ts;
 
return round($diff / 86400);
 
}
 
echo dateDiff("2012-01-28", "2012-01-27");
?>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.