[wp-trac] [WordPress Trac] #38774: Date and time APIs for posts make wrong timezone assumptions

WordPress Trac noreply at wordpress.org
Sun Nov 13 20:05:39 UTC 2016


#38774: Date and time APIs for posts make wrong timezone assumptions
--------------------------+-----------------------------
 Reporter:  Rarst         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Date/Time     |    Version:  4.6.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 WP doesn't store timezone information in "main" (non-GMT) post fields.
 Many of related APIs make a wide assumption that correct time zone is
 merely the one set in settings right now:

 {{{#!php
 <?php

 d( get_the_date( DATE_W3C ) ); // 2014-11-07T13:36:31+02:00

 add_filter( 'pre_option_timezone_string', function () {
         return 'America/New_York';
 } );

 d( get_the_date( DATE_W3C ) ); // 2014-11-07T13:36:31-05:00 < same time,
 different time zone
 }}}

 This is extremely brittle.

 Timezone change in settings would make API return invalid time for all
 existing posts. Import from an install with different timezone setting
 would make all created posts display invalid time. And so on.

 It would be more reliable to base API return on GMT post fields (which
 does by definition have timezone information) and then convert to
 currently set time zone setting for return.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38774>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list