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
This commit is contained in:
Pascal Birchler 2017-03-24 17:52:02 +00:00
parent 8b23276a6a
commit d142d7fa23
1 changed files with 1 additions and 1 deletions

View File

@ -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;
}