Skip to content

Instantly share code, notes, and snippets.

@amirasaran
Created December 4, 2016 15:13
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 amirasaran/708468de9d6b8bbba14d6b22cab9f20d to your computer and use it in GitHub Desktop.
Save amirasaran/708468de9d6b8bbba14d6b22cab9f20d to your computer and use it in GitHub Desktop.
php regex is_date_time function to validate date time
function is_date_time($value){
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])[T|\s]{1}([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/",$value))
{
return true;
}else{
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment