WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/20/2019 02:10:44 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Date/Time: Eliminate use of date_default_timezone_set() for determining DST status on General Options screen.

Time calculations should not need to rely on manipulating global PHP configuration state.

Props Rarst.
Fixes #46483.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options-general.php

    r45403 r45556  
    253253<span>
    254254    <?php
    255     // Set TZ so localtime works.
    256     date_default_timezone_set( $tzstring );
    257     $now = localtime( time(), true );
    258     if ( $now['tm_isdst'] ) {
     255    $now = new DateTime( 'now', new DateTimeZone( $tzstring ) );
     256    $dst = (bool) $now->format( 'I' );
     257
     258    if ( $dst ) {
    259259        _e( 'This timezone is currently in daylight saving time.' );
    260260    } else {
     
    297297        }
    298298    }
    299     // Set back to UTC.
    300     date_default_timezone_set( 'UTC' );
    301299    ?>
    302300    </span>
Note: See TracChangeset for help on using the changeset viewer.