@ 2016-11-28T17:31:29Z <?php
$vancouver = new \DateTimeZone('America/Vancouver');
$utc = new \DateTimeZone('UTC');
$timestamp1 = 1478422920;
$date1 = new \DateTime('@' . $timestamp1);
print '--- UTC ---' . PHP_EOL;
print $timestamp1 . PHP_EOL;
print $date1->format('c') . PHP_EOL;
print '--- UTC => Vancouver ---' . PHP_EOL;
$date1->setTimezone($vancouver);
print $date1->format('c') . PHP_EOL;
print $date1->format('Y-m-d\TH:i:s') . PHP_EOL;
print '--- Vancouver => UTC ---' . PHP_EOL;
$string1 = $date1->format('Y-m-d\TH:i:s');
$date2 = new \DateTime($string1, $vancouver);
$timestamp2 = $date2->getTimestamp();
print $timestamp2 . PHP_EOL;
print $date2->format('c') . PHP_EOL;
$date2->setTimezone($utc);
print $date2->format('c') . PHP_EOL;
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.5 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 --- UTC ---
1478422920
2016-11-06T09:02:00+00:00
--- UTC => Vancouver ---
2016-11-06T01:02:00-08:00
2016-11-06T01:02:00
--- Vancouver => UTC ---
1478419320
2016-11-06T01:02:00-07:00
2016-11-06T08:02:00+00:00
preferences:dark mode live preview
195.23 ms | 404 KiB | 220 Q