I'd like to validate UTC date, sent by the POST request, before inserting it into my database.
$date = "2014-08-11T16:32:13.000Z"
What is the best way to check if the date is correct?
I'd like to validate UTC date, sent by the POST request, before inserting it into my database.
$date = "2014-08-11T16:32:13.000Z"
What is the best way to check if the date is correct?
try {
$dt = new DateTime($date);
// $dt->format(DateTime::ATOM); // contains valid date
}catch(Exception $exception) {
// invalid $date
}