Last active
May 12, 2021 00:34
-
-
Save rafael-neri/87fb25ab0dfec13703604095f8517822 to your computer and use it in GitHub Desktop.
Check if date is valid from format specified
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 | |
function checkFormatDateTime(string $datetime, string $format): bool | |
{ | |
$d = \DateTime::createFromFormat($format, $datetime); | |
return $d !== false ? $d->format($format) == $datetime : false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment