Skip to content

Instantly share code, notes, and snippets.

@robozavri
Created June 20, 2018 11:58
Show Gist options
  • Save robozavri/b486226c4851187ced1c48dc430e03b3 to your computer and use it in GitHub Desktop.
Save robozavri/b486226c4851187ced1c48dc430e03b3 to your computer and use it in GitHub Desktop.
php datatime different
$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>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment