3v4l.org

run code in 300+ PHP versions simultaneously
<?php $format = 'Y-m-d'; $value = '14-09-13'; $hasTimeInfo = (strpbrk($format, 'HhGgis') !== false); $date = DateTime::createFromFormat($format, $value, new DateTimeZone($hasTimeInfo ? 'Asia/Jakarta' : 'UTC')); $errors = DateTime::getLastErrors(); if ($date === false || $errors['error_count'] || $errors['warning_count']) { echo 'return false'; print_r($error); return; } if (!$hasTimeInfo) { $date->setTime(0, 0, 0); } echo $date->getTimestamp();

preferences:
50.83 ms | 405 KiB | 5 Q