3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertToTimestamp($str) { $str = trim($str); if (!function_exists('date_create')) { $ts = strtotime($str); // Doku: Vor PHP 5.1.0 gab die Funktion -1 im Fehlerfall zurück. if ($ts === -1) $ts = false; return $ts; } $oDate = date_create($str); #if (is_object($oDate)) { if ($oDate instanceof DateTime ( { return (int)$oDate->format('U'); } return false; } var_dump( convertToTimestamp("2012-01-01") ); // 1325376000 echo "\n"; var_dump( convertToTimestamp("foo") ); // sollte false oder -1
Output for 5.3.0 - 5.3.16, 5.4.0 - 5.4.6
Parse error: syntax error, unexpected '(' in KHZ84 on line 15
Process exited with code 255.

preferences:
167.37 ms | 1395 KiB | 31 Q