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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.