Created
March 18, 2016 19:19
-
-
Save abresas/90cc713ffa2fe1bbf520 to your computer and use it in GitHub Desktop.
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
<?php | |
// returns a timezone that is at the given offset | |
// taking into consideration if the timezone | |
// is currently observing DST or not. | |
// | |
// offset: timezone offset in seconds | |
function tz_from_offset($offset) { | |
$tz = timezone_name_from_abbr(0, $offset, 0); | |
$date = date_create("now", new DateTimeZone($tz)); | |
if ($date->getOffset() != $offset) { | |
$tz = timezone_name_from_abbr(0, $offset, 1); | |
} | |
return $tz; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment