WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/24/2017 05:31:54 PM (5 years ago)
Author:
swissspidy
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r40306 r40324  
    14021402            // field with the site's timezone offset applied.
    14031403            if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) {
    1404                 $post_date_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_date ) - ( get_option( 'gmt_offset' ) * 3600 ) );
     1404                $post_date_gmt = get_gmt_from_date( $post->post_date );
    14051405            } else {
    14061406                $post_date_gmt = $post->post_date_gmt;
Note: See TracChangeset for help on using the changeset viewer.