Created
October 19, 2019 06:32
-
-
Save emarref/b5c21922899fb489015b9fe4de24e81b to your computer and use it in GitHub Desktop.
Shell script to convert a timestamp to NZ time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
$originTimeZone = 'UTC'; | |
$targetTimeZone = 'Pacific/Auckland'; | |
//////////////////////// | |
$timestamp = implode(' ', array_slice($_SERVER['argv'], 1)); | |
$origin = new DateTimeZone($originTimeZone); | |
$target = new DateTimeZone($targetTimeZone); | |
$date = (new DateTimeImmutable($timestamp, $origin))->setTimeZone($origin); | |
//////////////////////// | |
printf( | |
"%s: %s\n%s: %s\n", | |
$originTimeZone, | |
$date->format('r'), | |
$targetTimeZone, | |
$date->setTimezone($target)->format('r') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment