Skip to content

Instantly share code, notes, and snippets.

@stevekirkby
Created June 30, 2013 10:36
Show Gist options
  • Save stevekirkby/5894674 to your computer and use it in GitHub Desktop.
Save stevekirkby/5894674 to your computer and use it in GitHub Desktop.
PHP - Time since date
$start_date = new DateTime('2007-09-01 04:10:58');
$since_start = $start_date->diff(new DateTime('2012-09-11 10:25:00'));
echo $since_start->days.' days total<br>';
echo $since_start->y.' years<br>';
echo $since_start->m.' months<br>';
echo $since_start->d.' days<br>';
echo $since_start->h.' hours<br>';
echo $since_start->i.' minutes<br>';
echo $since_start->s.' seconds<br>';
$totalSeconds = ($since_start->days) *3600*24;
echo $totalSeconds.' total seconds<br>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment