PHP Function to Validate Date Format

1
2
3
4
5
6
7
8
9
10
11
12
function cvf_ps_check_date_format($date) {

    // define your format here
    $format = "m/d/Y";
    $date_format= DateTime::createFromFormat($format, $date);
   
    if(!$date_format) {
        return false;
    } else {
        return true;
    }
}


Do you need help with a project? or have a new project in mind that you need help with?

Contact Me