3v4l.org
- online PHP shell, test in 80+ different PHP versions!
<?php function is_valid_date($date) { if (preg_match('/^((19|20)\\d\\d)-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01]) ([01]\d|2[0123]):([0-5]\d):([0-5]\d)$/', $date, $matches)){ return checkdate($matches[3], $matches[4], $matches[1]); } return false; } var_dump(is_valid_date("2012-12-02 15:30:00")); //true ?>
based on ZjD44
Output
VLD opcodes
Performance
References
Output for 4.3.0 - 5.5.0beta2
bool(true)
Follow us on Twitter