Answers for "php regex check if date is datetime or date"

PHP
1

regex to check date format php

if (preg_match("/\d{4}\-\d{2}-\d{2}/", $date)) {
    echo 'true';
} else {
    echo 'false';
}
Posted by: Guest on March-23-2020
1

check if date is past php

$date = new DateTime($event['date']);
$now = new DateTime();
if($date < $now) {
    echo 'Date is in the past';
}
Posted by: Guest on March-27-2021

Browse Popular Code Answers by Language