Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

check date php

function validateDate($date, $format = 'Y-m-d')
{
    $d = DateTime::createFromFormat($format, $date);
    // The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
    return $d && $d->format($format) === $date;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #date #php
ADD COMMENT
Topic
Name
7+8 =