Skip to content

Instantly share code, notes, and snippets.

@miwebguy
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save miwebguy/205136018d6144614252 to your computer and use it in GitHub Desktop.

Select an option

Save miwebguy/205136018d6144614252 to your computer and use it in GitHub Desktop.
Check Valid Y-m-d
<?php
/**
* Check for Valid Date Entry
*/
public function validDateString($datestring)
{
if(!preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$datestring)
|| date("Y-m-d", strtotime($datestring))!=$datestring)
return false;
else
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment