diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 3c4a301298..bf814d5baf 100644
a
|
b
|
function current_time( $type, $gmt = 0 ) { |
69 | 69 | case 'timestamp': |
70 | 70 | return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); |
71 | 71 | default: |
72 | | return ( $gmt ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ); |
| 72 | return ( $gmt ) ? gmdate( $type ) : gmdate( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
diff --git a/tests/phpunit/tests/date/currentTime.php b/tests/phpunit/tests/date/currentTime.php
new file mode 100644
index 0000000000..209eb128c6
-
|
+
|
|
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @group date |
| 5 | * @group datetime |
| 6 | */ |
| 7 | class Tests_Date_CurrentTime extends WP_UnitTestCase { |
| 8 | |
| 9 | public function test_should_work_with_changed_timezone() { |
| 10 | |
| 11 | $format = 'Y-m-d H:i:s'; |
| 12 | $timezone_string = 'America/Regina'; |
| 13 | update_option( 'timezone_string', $timezone_string ); |
| 14 | $datetime = new DateTime( 'now', new DateTimeZone( $timezone_string ) ); |
| 15 | |
| 16 | date_default_timezone_set( $timezone_string ); |
| 17 | $this->assertEquals( gmdate( $format ), current_time( $format, true ) ); |
| 18 | $this->assertEquals( $datetime->format( $format ), current_time( $format ) ); |
| 19 | |
| 20 | date_default_timezone_set( 'UTC' ); |
| 21 | $this->assertEquals( gmdate( $format ), current_time( $format, true ) ); |
| 22 | $this->assertEquals( $datetime->format( $format ), current_time( $format ) ); |
| 23 | } |
| 24 | } |