3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function validaData($date, $format = 'Y-m-d H:i:s') { $v_date = date_create_from_format($format, $date); $v_date = date_format($v_date, $format); return ($v_date && $v_date == $date); } var_dump(validaData('2014-02-28 12:12:12')); # true var_dump(validaData('2014-02-30 12:12:12')); # false var_dump(validaData('2014-02-28', 'Y-m-d')); # true var_dump(validaData('28/02/2014', 'd/m/Y')); # true var_dump(validaData('30/02/2014', 'd/m/Y')); # false var_dump(validaData('14:50', 'H:i')); # true var_dump(validaData('14:77', 'H:i')); # false var_dump(validaData(14, 'H')); # true var_dump(validaData('14', 'H')); # true
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
bool(true) bool(false) bool(true) bool(true) bool(false) bool(true) bool(false) bool(true) bool(true)
Output for hhvm-3.10.0 - 3.12.0
bool(true) bool(false) bool(true) bool(true) bool(false) bool(true) bool(false) Catchable fatal error: Argument 2 passed to date_create_from_format() must be an instance of string, int given in /in/lHqhb on line 4
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.2.17
Fatal error: Call to undefined function date_create_from_format() in /in/lHqhb on line 4
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/lHqhb on line 17
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: date_create_from_format() in /in/lHqhb on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: date_create_from_format() in /in/lHqhb on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: date_create_from_format() in /in/lHqhb on line 4