3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php echo date_default_timezone_set . "\n" $vUnixTime = "1414802161"; echo("Original timestamp: " . $vUnixTime . "\n"); $vOriginalTimezone = "UTC"; $vDesiredTimezone = "EST"; $oBaseTimeZone = new DateTimeZone($vOriginalTimezone); // user time zone $oCurrentTimeZone = new DateTimeZone($vDesiredTimezone); $vIsoTime = date("Y-m-d H:i:s",$vUnixTime); $oBaseTime = new DateTime($vIsoTime,$oBaseTimeZone); $oBaseTime->setTimezone($oCurrentTimeZone); echo("UTC to EST modified Timestamp: " . $oBaseTime->getTimestamp() . "\n"); $vTimeStamp = "1414802161"; $vOriginalTimezone = "EST"; $vDesiredTimezone = "UTC"; $oBaseTimeZone = new DateTimeZone($vOriginalTimezone); // user time zone $oCurrentTimeZone = new DateTimeZone($vDesiredTimezone); $vIsoTime = date("Y-m-d H:i:s",$vUnixTime); $oBaseTime = new DateTime($vIsoTime,$oBaseTimeZone); $oBaseTime->setTimezone($oCurrentTimeZone); echo("EST to UTC modified Timestamp: " . $oBaseTime->getTimestamp() . "\n"); $vOriginalTimezone = "PST"; $vDesiredTimezone = "EST"; $oBaseTimeZone = new DateTimeZone($vOriginalTimezone); // user time zone $oCurrentTimeZone = new DateTimeZone($vDesiredTimezone); $vIsoTime = date("Y-m-d H:i:s",$vUnixTime); $oBaseTime = new DateTime($vIsoTime,$oBaseTimeZone); $oBaseTime->setTimezone($oCurrentTimeZone); echo("PST to EST modified Timestamp: " . $oBaseTime->getTimestamp() . "\n"); ?>
based on nT5nV
Output for 5.4.0 - 5.4.34
Parse error: syntax error, unexpected '$vUnixTime' (T_VARIABLE), expecting ',' or ';' in /in/Uhi4L on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /in/Uhi4L on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /in/Uhi4L on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `','' or `';'' in /in/Uhi4L on line 5
Process exited with code 255.