WordPress.org

Make WordPress Core

Ticket #20942: 20942.patch

File 20942.patch, 1020 bytes (added by winterDev, 3 years ago)

Adjusted and re-uploaded patch per suggestion from georgestephanis: "Do you need to account for a negative offset in line 1874 ? swap out '+' . $offset / 3600 . ' hours'); with ( $offset < 0 ? '-' : '+' ) . abs( $offset / 3600 ) . ' hours' ); -- perhaps? If it works as is with the + so be it, it's just my thoughts after a sixty second glance."

  • wp-includes/formatting.php

     
    1 <?php 
     1?<?php 
    22/** 
    33 * Main WordPress Formatting API. 
    44 * 
     
    18681868        $tz = get_option('timezone_string'); 
    18691869        if ( $tz ) { 
    18701870                date_default_timezone_set( $tz ); 
    1871                 $datetime = new DateTime( $string ); 
    1872                 $datetime->setTimezone( new DateTimeZone('UTC') ); 
    1873                 $offset = $datetime->getOffset(); 
    1874                 $datetime->modify( '+' . $offset / 3600 . ' hours'); 
    1875                 $string_gmt = gmdate($format, $datetime->format('U')); 
     1871                $datetimeObj = date_create( $string ); 
     1872                $datetimeObj = date_timezone_set( $datetimeObj, timezone_open('UTC') ); 
     1873                $offset = date_offset_get($datetimeObj); 
     1874                $datetimeObj = date_modify( $datetimeObj, ($offset < 0 ? '-':'+') . abs($offset / 3600) . ' hours'); 
     1875                $string_gmt = gmdate( $format, date_format($datetimeObj, 'U') ); 
    18761876 
    18771877                date_default_timezone_set('UTC'); 
    18781878        } else {