📜  php 验证日期格式 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:59.382000             🧑  作者: Mango

代码示例2
function isValidDate(string $date, string $format = 'Y-m-d'): bool
{
    $dateObj = DateTime::createFromFormat($format, $date);
    return $dateObj && $dateObj->format($format) == $date;
}