diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
index 7e3e5636c4..749d37a5d8 100644
|
|
class WP_REST_Posts_Controller extends WP_REST_Controller { |
1399 | 1399 | // #38883). In this case, shim the value based on the `post_date` |
1400 | 1400 | // field with the site's timezone offset applied. |
1401 | 1401 | if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { |
1402 | | $post_date_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_date ) - ( get_option( 'gmt_offset' ) * 3600 ) ); |
| 1402 | $post_date_gmt = get_gmt_from_date( $post->post_date ); |
1403 | 1403 | } else { |
1404 | 1404 | $post_date_gmt = $post->post_date_gmt; |
1405 | 1405 | } |
diff --git tests/phpunit/tests/rest-api/rest-posts-controller.php tests/phpunit/tests/rest-api/rest-posts-controller.php
index abc30d40ce..a25fa4acb9 100644
|
|
class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te |
2237 | 2237 | |
2238 | 2238 | $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); |
2239 | 2239 | } |
2240 | | |
| 2240 | |
2241 | 2241 | public function test_empty_post_date_gmt_shimmed_using_post_date() { |
2242 | 2242 | global $wpdb; |
2243 | 2243 | |
2244 | 2244 | wp_set_current_user( self::$editor_id ); |
2245 | | update_option( 'timezone_string', '' ); |
2246 | | update_option( 'gmt_offset', -6 ); |
| 2245 | update_option( 'timezone_string', 'America/Chicago' ); |
2247 | 2246 | |
2248 | 2247 | // Need to set dates using wpdb directly because `wp_update_post` and |
2249 | 2248 | // `wp_insert_post` have additional validation on dates. |
… |
… |
class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te |
2288 | 2287 | $this->assertEquals( $post->post_date_gmt, '2016-02-23 19:00:00' ); |
2289 | 2288 | |
2290 | 2289 | update_option( 'timezone_string', '' ); |
2291 | | update_option( 'gmt_offset', 0 ); |
2292 | 2290 | } |
2293 | 2291 | |
2294 | 2292 | public function test_update_post_slug() { |