Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Checking the date entered is according to a predefined format or not ?

    • 0
    • 1
    • 1
    • 4
    • 2
    • 0
    • 0
    • 0
    • 245
    Comment on it

    Checking the date entered by the user correct of not as according to a predefined format or not.

    Example 1)

    $format  = 'd-m-Y';
    $input   = 'asasasawasa-sldjs';
    $date    = DateTime::createFromFormat($format, $input);
    if($date) 
      echo 'The Date you entered is correct';
    else
      echo 'The date you entered is Incorrect';
    

    OUTPUT: The Date you entered is incorrect

    Example 2)

    $format  = 'd-m-Y';
    $input   = '09-12-2013';
    $date    = DateTime::createFromFormat($format, $input);
    if($date) 
          echo 'The Date you entered is Correct';
    else
          echo 'The date you entered is Incorrect';
    

    OUTPUT: The Date you entered is Correct

 2 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: