Created
June 16, 2016 03:49
-
-
Save zgulde/52c36152fede0130cce742f0e3f77e37 to your computer and use it in GitHub Desktop.
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
| <?php | |
| // takes a start and end date as a string and returns the number of days | |
| // between them | |
| function diffInDays($start, $end) | |
| { | |
| $start = new DateTime($start); | |
| $end = new DateTime($end); | |
| return date_diff($start, $end)->days; | |
| } | |
| diffInDays('today', 'dec 25'); // 191 | |
| diffInDays('2015-01-24', '2015-01-24'); // 0 | |
| diffInDays('2015-01-24', '2015-02-07'); // 14 | |
| diffInDays('2015-01-24', '2015-05-13'); // 109 | |
| diffInDays('2015-01-24', '2016-04-24'); // 456 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Zach