Created
June 30, 2013 10:36
-
-
Save stevekirkby/5894674 to your computer and use it in GitHub Desktop.
PHP - Time since date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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