3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?PHP function mysql_date($in) { //Function takes a string in as form data, splits it by a list of //possible separators. If the resulting array has a length of 3, the //function returns a MySQL compatible date() string, else returns false // //Also, uses the checkdate() [PHP core function] to validate the date. $output = false; $d = preg_split('#[-/:. ]#', trim($in)); if (is_array($d) && count($d) == 3) { if (strlen($d[2]) == 2) { $d[2] = '20'.$d[2]; } if (checkdate($d[0], $d[1], $d[2])) { $output = "$d[2]-$d[0]-$d[1]"; } } return $output; } echo mysql_date('05/07/2014');
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
2014-05-07
Output for hhvm-3.10.0

Process exited with code 137.