wp_timezone_override_offset() WordPress Function

The wp_timezone_override_offset() function allows you to set the default timezone for your WordPress site. This can be useful if you want all dates and times on your site to be displayed in a specific timezone.

wp_timezone_override_offset() #

gmt_offset modification for smart timezone handling.


Description

Overrides the gmt_offset option if we have a timezone_string available.


Top ↑

Return

(float|false) Timezone GMT offset, false otherwise.


Top ↑

Source

File: wp-includes/functions.php

function wp_timezone_override_offset() {
	$timezone_string = get_option( 'timezone_string' );
	if ( ! $timezone_string ) {
		return false;
	}

	$timezone_object = timezone_open( $timezone_string );
	$datetime_object = date_create();
	if ( false === $timezone_object || false === $datetime_object ) {
		return false;
	}
	return round( timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS, 2 );
}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More