PHP Function to Validate Date Format

Date Posted: August 16, 2014, 3:57 am


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;
    }
}

About author


Carl Victor Fontanos

A fine gentleman specializing in front-end and back-end development with extensive experience building high performance web applications that keeps users engaged and help businesses grow.

 
Hire Me