Make WordPress Core

Changeset 17958


Ignore:
Timestamp:
05/18/2011 06:56:42 PM (14 years ago)
Author:
ryan
Message:

Revert part of [17920]. Support for empty tz must remain. Props johnjamesjacoby. fixes #17448

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r17925 r17958  
    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. The DateTime and DateTimeZone classes are used to respect
     1592 * time zone differences in DST.
    15921593 *
    15931594 * @since 1.2.0
     
    16011602    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);
    16021603    $tz = get_option('timezone_string');
    1603     date_default_timezone_set( $tz );
    1604     $datetime = new DateTime( $string );
    1605     $datetime->setTimezone( new DateTimeZone('UTC') );
    1606     $offset = $datetime->getOffset();
    1607     $datetime->modify( '+' . $offset / 3600 . ' hours');
    1608     $string_gmt = gmdate($format, $datetime->format('U'));
    1609     date_default_timezone_set('UTC');
     1604    if ( $tz ) {
     1605        date_default_timezone_set( $tz );
     1606        $datetime = new DateTime( $string );
     1607        $datetime->setTimezone( new DateTimeZone('UTC') );
     1608        $offset = $datetime->getOffset();
     1609        $datetime->modify( '+' . $offset / 3600 . ' hours');
     1610        $string_gmt = gmdate($format, $datetime->format('U'));
     1611
     1612        date_default_timezone_set('UTC');
     1613    } else {
     1614        $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
     1615        $string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600);
     1616    }
    16101617    return $string_gmt;
    16111618}
Note: See TracChangeset for help on using the changeset viewer.