WordPress.org

Make WordPress Core

Ticket #17448: 17448.patch

File 17448.patch, 828 bytes (added by johnjamesjacoby, 3 years ago)
  • formatting.php

     
    15881588 * 
    15891589 * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the 
    15901590 * value of the 'gmt_offset' option. Return format can be overridden using the 
    1591  * $format parameter. 
     1591 * $format parameter. 
    15921592 * 
    15931593 * @since 1.2.0 
    15941594 * 
     
    16001600function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') { 
    16011601        preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches); 
    16021602        $tz = get_option('timezone_string'); 
    1603         date_default_timezone_set( $tz ); 
     1603        if ( !empty( $tz ) ) 
     1604                date_default_timezone_set( $tz ); 
    16041605        $datetime = new DateTime( $string ); 
    16051606        $datetime->setTimezone( new DateTimeZone('UTC') ); 
    16061607        $offset = $datetime->getOffset();