3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $today = date('Y-m-d'); $todayTimestamp = strtotime($today); $dateTimeZone = new DateTimeZone('UTC'); $timezoneName = 'America/Vancouver'; $dateTimeZone = new DateTimeZone($timezoneName); $dateTime = new DateTime('@'.$todayTimestamp); $dateTime->setTimezone($dateTimeZone); $todayLocal = $dateTime->format('Y-m-d H:i:s'); $todayLocalTimestamp = strtotime($todayLocal); echo "$todayTimestamp\n"; echo $todayLocalTimestamp;
based on Fac1Q
Output for 5.2.0 - 7.2.0
1430344800 1430312400
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTimeZone' not found in /in/BJa1m on line 6
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/BJa1m on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/BJa1m on line 6