Skip to content

Instantly share code, notes, and snippets.

@assertchris
Created March 22, 2012 10:47
Show Gist options
  • Save assertchris/2157648 to your computer and use it in GitHub Desktop.
Save assertchris/2157648 to your computer and use it in GitHub Desktop.
Handy date diff function
function diff($start, $end)
{
$start = new DateTime($start);
$end = new DateTime($end);
$interval = $start->diff($end);
return array(
"years" => $interval->format("%y"),
"months" => $interval->format("%m"),
"days" => $interval->format("%d")
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment