php check if date valid code example
Example 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);
}
Example 2: check if date is past php
$date = new DateTime($event['date']);
$now = new DateTime();
if($date < $now) {
echo 'Date is in the past';
}