wp_timezone_override_offset

Gmt_offset modification for smart timezone handling.

Description

(float|false) wp_timezone_override_offset(); 

Overrides the gmt_offset option if we have a timezone_string available.

Returns (float|false)

Timezone GMT offset, false otherwise.


Usage

  1. if ( !function_exists( 'wp_timezone_override_offset' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_timezone_override_offset(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_timezone_override_offset() { 
  2. if ( !$timezone_string = get_option( 'timezone_string' ) ) { 
  3. return false; 
  4.  
  5. $timezone_object = timezone_open( $timezone_string ); 
  6. $datetime_object = date_create(); 
  7. if ( false === $timezone_object || false === $datetime_object ) { 
  8. return false; 
  9. return round( timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS, 2 );