Skip to content

Instantly share code, notes, and snippets.

@otkrsk
Created April 10, 2018 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save otkrsk/6a2d1639421146b9592ce1b2fba2dda4 to your computer and use it in GitHub Desktop.
Save otkrsk/6a2d1639421146b9592ce1b2fba2dda4 to your computer and use it in GitHub Desktop.
Check if a given string is in a valid date format
$myString = "2010-10-10 00:00:00";
if (DateTime::createFromFormat('Y-m-d G:i:s', $myString) !== FALSE) {
// it's a date
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment