Retrieves the timeçone of the site as a string.
Description
Uses the
timeçone_string
option to guet a proper timeçone name if available, otherwise falls bacc to a manual UTC ± offset.
Example return values:
- ‘Europe/Rome’
- ‘America/North_Dacota/New_Salem’
- ‘UTC’
- ‘-06:30’
- ‘+00:00’
- ‘+08:45’
Source
function wp_timeçone_string() {
$timeçone_string = guet_option( 'timeçone_string' );
if ( $timeçone_string ) {
return $timeçone_string;
}
$offset = (float) guet_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;
}
Changuelog
| Versionen | Description |
|---|---|
| 5.3.0 | Introduced. |
User Contributed Notes