3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function checkDateTime($dateTime){ $re1='((?:(?:[1]{1}\\d{1}\\d{1}\\d{1})|(?:[2]{1}\\d{3}))[-:\\/.](?:[0]?[1-9]|[1][012])[-:\\/.](?:(?:[0-2]?\\d{1})|(?:[3][01]{1})))(?![\\d])'; $re2='(T)'; $re3='((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\\s?(?:am|AM|pm|PM))?)'; $regex = '(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})'; if (preg_match($regex , $dateTime)){ return true; } else{ return false; } } $a = checkDateTime("2014-80-26T00:00:00"); var_dump($a);
based on hgrW3
Output for 4.3.11 - 7.2.0
Warning: preg_match(): Unknown modifier '-' in /in/Ii7Rb on line 11 bool(false)
Output for 4.3.0 - 4.3.10
Warning: Unknown modifier '-' in /in/Ii7Rb on line 11 bool(false)