Skip to content

Commit e9fc71b

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@45556 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e283457 commit e9fc71b

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/wp-admin/options-general.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@
252252
<p class="timezone-info">
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 {
261261
_e( 'This timezone is currently in standard time.' );
@@ -296,8 +296,6 @@
296296
_e( 'This timezone does not observe daylight saving time.' );
297297
}
298298
}
299-
// Set back to UTC.
300-
date_default_timezone_set( 'UTC' );
301299
?>
302300
</span>
303301
</p>

0 commit comments

Comments
 (0)