3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $output = array(); $txt='2014-14-26T00:00:00'; $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_all ("/".$re1.$re2.$re3."/is", $txt, $matches)){ if(preg_match($regex, $txt)){ $output["status"] = "error"; $output["reason"] = "not valid date"; print_r($output); } else{ $output["status"] = "ok"; $output["reason"] = "valid date"; print_r($output); }
based on 4dC7X
Output for 4.3.11 - 7.2.0
Warning: preg_match(): Unknown modifier '-' in /in/79InF on line 16 Array ( [status] => ok [reason] => valid date )
Output for 4.3.0 - 4.3.10
Warning: Unknown modifier '-' in /in/79InF on line 16 Array ( [status] => ok [reason] => valid date )