Created
September 17, 2020 08:06
-
-
Save sumitpore/d9c6434e16088f558149d383c02e0541 to your computer and use it in GitHub Desktop.
WordPress derive Timezone from gmt_offset option
This file contains hidden or 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
function wp_timezone_object_from_gmt_offset() { | |
$min = 60 * get_option('gmt_offset'); | |
$sign = $min < 0 ? "-" : "+"; | |
$absmin = abs($min); | |
$tz = sprintf("%s%02d%02d", $sign, $absmin/60, $absmin%60); | |
return new DateTimeZone( $tz ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment