Answers for "check if datetime is valid php"

PHP
1

php check if input is date

function isRealDate($date) { 
    if (false === strtotime($date)) { 
        return false;
    } 
    list($year, $month, $day) = explode('-', $date); 
    return checkdate($month, $day, $year);
}
Posted by: Guest on November-08-2020
0

php check valid time format

function isValidDate(string $date, string $format = 'Y-m-d'): bool
{
    $dateObj = DateTime::createFromFormat($format, $date);
    return $dateObj && $dateObj->format($format) == $date;
}
Posted by: Guest on August-07-2021

Code answers related to "check if datetime is valid php"

Browse Popular Code Answers by Language