From d142d7fa2368e9388377c4b2e5a47b45b9a8c51c Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 24 Mar 2017 17:52:02 +0000 Subject: [PATCH] REST API: Use `get_gmt_from_date()` when preparing a draft post for response. This prevents wrong dates when dealing with DST, see [40115] and [40284]. Props nerrad. Fixes #40136. Merges [40284] and [40324] to the 4.7 branch. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40325 602fd350-edb4-49c9-b593-d223f7449a82 --- .../rest-api/endpoints/class-wp-rest-posts-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index b55620db73..05489359da 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -1393,7 +1393,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { // #38883). In this case, shim the value based on the `post_date` // field with the site's timezone offset applied. if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { - $post_date_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_date ) - ( get_option( 'gmt_offset' ) * 3600 ) ); + $post_date_gmt = get_gmt_from_date( $post->post_date ); } else { $post_date_gmt = $post->post_date_gmt; }