Return to Snippet

Revision: 69966
at October 19, 2015 21:19 by smagic39


Initial Code
function checkDateFormat($date)
{
    //match the format of the date
    if (preg_match ("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/", $date, $parts))
    {
        //check weather the date is valid of not
        if(checkdate($parts[2],$parts[3],$parts[1]))
            return true;
        else
        return false;
    }
    else
        return false;
}

Initial URL

                                

Initial Description
"YYYY-MM-DD" change pattern your fit code

Initial Title
Date format validation in PHP

Initial Tags

                                

Initial Language
PHP