Select Page

How to validate a date format using PHP

To check whether the date entered is in the correct format

NOTE: We will use the following date format within this example YYYY-MM-DD


  • Use the preg_match ‘Perform a regular expression match’  PHP function available for PHP 4 & 5 
  • Find the correct expression
  • And use the following code to check for the date format
        $msg = "Valid date";
        $msg = "Invalid date";

Related Articles

Last Updated On March 22, 2018

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Special Offers