Skip to content

Instantly share code, notes, and snippets.

@makingthingswork
Last active November 19, 2020 14:34
Show Gist options
  • Save makingthingswork/f81ba03d1eb523ad6af8a1eabb1634f6 to your computer and use it in GitHub Desktop.
Save makingthingswork/f81ba03d1eb523ad6af8a1eabb1634f6 to your computer and use it in GitHub Desktop.
Validate date
<?php
function valid_date(date,format='Y-m-d'){
d = DateTime::createFromFormat(format, date);
return d && (d->format(format) == date);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment