Created
December 28, 2012 06:25
-
-
Save amitchhajer/4395059 to your computer and use it in GitHub Desktop.
Validating php date and date time
This file contains 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
Validating a date from format yyyy-mm-dd | |
$date = DateTime::createFromFormat('Y-m-d', $generatedFrom); | |
if (!($date instanceof DateTime)) { | |
throw new ValidationError('Not valid start date'); | |
} | |
Similarly other formats can be validated. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment