Last active
December 11, 2015 12:29
-
-
Save sglessard/4601445 to your computer and use it in GitHub Desktop.
SGLFLTS - DateTime : tomorrow and yesterday (symfony2)
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
| // string input ($date = '2013-01-01';) | |
| $day = \DateTime::createFromFormat('Y-m-d', $date); | |
| $date_errors = \DateTime::getLastErrors(); | |
| if ($date_errors['warning_count'] + $date_errors['error_count'] > 0) { | |
| throw $this->createNotFoundException('Input date does not exist.'); | |
| } | |
| $next_day = clone $day; | |
| $next_day->add(new \DateInterval('P1D')); | |
| $previous_day = clone $day; | |
| $previous_day->sub(new \DateInterval('P1D')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment