diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 3c4a301298..4f30d98d13 100644
a
|
b
|
function current_time( $type, $gmt = 0 ) { |
88 | 88 | * @param string $dateformatstring Format to display the date. |
89 | 89 | * @param int|bool $timestamp_with_offset Optional. A sum of Unix timestamp and timezone offset in seconds. |
90 | 90 | * Default false. |
91 | | * @param bool $gmt Optional. Whether to use GMT timezone. Default false. |
| 91 | * @param bool $gmt Optional. Whether to use GMT timezone. Only applies if timestamp is not provided. Default false. |
92 | 92 | * |
93 | 93 | * @return string The date, translated if locale specifies it. |
94 | 94 | */ |
… |
… |
function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = fa |
126 | 126 | $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' ); |
127 | 127 | $timezone_formats_re = implode( '|', $timezone_formats ); |
128 | 128 | if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) { |
129 | | $timezone_string = get_option( 'timezone_string' ); |
| 129 | $timezone_string = get_option( 'timezone_string' ); |
| 130 | if ( false === $timestamp_with_offset && $gmt ) { |
| 131 | $timezone_string = 'UTC'; |
| 132 | } |
130 | 133 | if ( $timezone_string ) { |
131 | 134 | $timezone_object = timezone_open( $timezone_string ); |
132 | 135 | $date_object = date_create( null, $timezone_object ); |
… |
… |
function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = fa |
150 | 153 | * @param string $j Formatted date string. |
151 | 154 | * @param string $req_format Format to display the date. |
152 | 155 | * @param int $i A sum of Unix timestamp and timezone offset in seconds. |
153 | | * @param bool $gmt Whether to convert to GMT for time. Default false. |
| 156 | * @param bool $gmt Whether to use GMT timezone. Only applies if timestamp was not provided. Default false. |
154 | 157 | */ |
155 | 158 | $j = apply_filters( 'date_i18n', $j, $req_format, $i, $gmt ); |
156 | 159 | return $j; |
diff --git a/tests/phpunit/tests/date/dateI18n.php b/tests/phpunit/tests/date/dateI18n.php
index e92f58de6f..da64bd6502 100644
a
|
b
|
public function test_should_use_custom_timestamp() { |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function test_date_should_be_in_gmt() { |
17 | | $this->assertEquals( strtotime( date( 'Y-m-d H:i:s' ) ), strtotime( date_i18n( 'Y-m-d H:i:s', false, true ) ), 'The dates should be equal', 2 ); |
| 17 | $this->assertEquals( strtotime( date( DATE_RFC3339 ) ), strtotime( date_i18n( DATE_RFC3339, false, true ) ), 'The dates should be equal', 2 ); |
18 | 18 | } |
19 | 19 | |
20 | 20 | public function test_custom_timestamp_ignores_gmt_setting() { |
… |
… |
public function test_custom_timezone_setting() { |
30 | 30 | public function test_date_should_be_in_gmt_with_custom_timezone_setting() { |
31 | 31 | update_option( 'timezone_string', 'America/Regina' ); |
32 | 32 | |
33 | | $this->assertEquals( strtotime( date( 'Y-m-d H:i:s' ) ), strtotime( date_i18n( 'Y-m-d H:i:s', false, true ) ), 'The dates should be equal', 2 ); |
| 33 | $this->assertEquals( strtotime( date( DATE_RFC3339 ) ), strtotime( date_i18n( DATE_RFC3339, false, true ) ), 'The dates should be equal', 2 ); |
34 | 34 | } |
35 | 35 | |
36 | 36 | public function test_date_should_be_in_gmt_with_custom_timezone_setting_and_timestamp() { |