Uses
Uses | Description |
---|---|
wp-includes/option.php: get_option() | Retrieves an option value based on an option name. |
Retrieves the timezone from site settings as a string.
Uses the timezone_string
option to get a proper timezone if available, otherwise falls back to an offset.
(string) PHP timezone string or a ±HH:MM offset.
File: wp-includes/functions.php
function wp_timezone_string() { $timezone_string = get_option( 'timezone_string' ); if ( $timezone_string ) { return $timezone_string; } $offset = (float) get_option( 'gmt_offset' ); $hours = (int) $offset; $minutes = ( $offset - $hours ); $sign = ( $offset < 0 ) ? '-' : '+'; $abs_hour = abs( $hours ); $abs_mins = abs( $minutes * 60 ); $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins ); return $tz_offset; }
Version | Description |
---|---|
5.3.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_timezone_string