3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set(null); $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"); ?>
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: date_default_timezone_set(): Passing null to parameter #1 ($timezoneId) of type string is deprecated in /in/nT5nV on line 2 Notice: date_default_timezone_set(): Timezone ID '' is invalid in /in/nT5nV on line 2 Original timestamp: 1414802161 UTC to EST modified Timestamp: 1414805761 EST to UTC modified Timestamp: 1414823761 PST to EST modified Timestamp: 1414834561
Output for 5.5.10 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30
Notice: date_default_timezone_set(): Timezone ID '' is invalid in /in/nT5nV on line 2 Original timestamp: 1414802161 UTC to EST modified Timestamp: 1414805761 EST to UTC modified Timestamp: 1414823761 PST to EST modified Timestamp: 1414834561
Output for 8.0.13
Notice: date_default_timezone_set(): Timezone ID '' is invalid in /in/nT5nV on line 2 Original timestamp: 1414802161 UTC to EST modified Timestamp: 1414802161 EST to UTC modified Timestamp: 1414820161 PST to EST modified Timestamp: 1414830961
Output for 7.3.32 - 7.3.33
Original timestamp: 1414802161 UTC to EST modified Timestamp: 1414802161 EST to UTC modified Timestamp: 1414820161 PST to EST modified Timestamp: 1414830961
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.9
Notice: date_default_timezone_set(): Timezone ID '' is invalid in /in/nT5nV on line 2 Original timestamp: 1414802161 UTC to EST modified Timestamp: 1414805761 EST to UTC modified Timestamp: 1414820161 PST to EST modified Timestamp: 1414830961
Output for 5.2.0 - 5.2.17
Notice: date_default_timezone_set(): Timezone ID '' is invalid in /in/nT5nV on line 2 Original timestamp: 1414802161 Fatal error: Call to undefined method DateTime::getTimestamp() in /in/nT5nV on line 19
Process exited with code 255.
Output for 5.1.2 - 5.1.6
Notice: date_default_timezone_set(): Timezone ID '' is invalid in /in/nT5nV on line 2 Original timestamp: 1414802161 Fatal error: Class 'DateTimeZone' not found in /in/nT5nV on line 11
Process exited with code 255.
Output for 5.1.0 - 5.1.1
Original timestamp: 1414802161 Fatal error: Class 'DateTimeZone' not found in /in/nT5nV on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function date_default_timezone_set() in /in/nT5nV on line 2
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: date_default_timezone_set() in /in/nT5nV on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: date_default_timezone_set() in /in/nT5nV on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: date_default_timezone_set() in /in/nT5nV on line 2

preferences:
284.89 ms | 401 KiB | 459 Q