Skip to content

Instantly share code, notes, and snippets.

@madeinnordeste
Created May 3, 2014 01:08
Show Gist options
  • Save madeinnordeste/f55d8578c32b16c4a6ba to your computer and use it in GitHub Desktop.
Save madeinnordeste/f55d8578c32b16c4a6ba to your computer and use it in GitHub Desktop.
PHP - Datetime Diff
<?php
$from = new DateTime('0000-00-00 00:00:00');
$to = new DateTime('now');
$interval = $to->diff($from);
//2011 years, 4 months, 5 days, 11 hours, 13 minutes, 49 seconds
echo $interval->format('%Y years, %m months, %d days, %H hours, %i minutes, %s seconds');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment