[wp-trac] [WordPress Trac] #9588: time() is not GMT time()

WordPress Trac wp-trac at lists.automattic.com
Thu Sep 24 16:59:16 UTC 2009


#9588: time() is not GMT time()
--------------------------------+-------------------------------------------
  Reporter:  Denis-de-Bernardy  |        Type:  defect (bug)           
    Status:  reopened           |    Priority:  normal                 
 Milestone:  2.9                |   Component:  Date/Time              
   Version:  2.8                |    Severity:  normal                 
Resolution:                     |    Keywords:  has-patch needs-testing
--------------------------------+-------------------------------------------

Comment(by Otto42):

 The differences you're seeing between date calls is because the
 current_time call causes WordPress to load the gmt_offset, which then
 corrects the default timezone setting. PHP's date is subject to timezone
 adjustment, it's not supposed to be GMT. If you want GMT, you call gmdate.

 In other words, this will demonstrate the problem (if you call it early
 enough in the execution):

 {{{
 dump($unixmonth, date('Y-m-d', $unixmonth));
 get_option( 'gmt_offset' );
 dump($unixmonth, date('Y-m-d', $unixmonth));
 }}}

 The correct solution to this is to make WordPress call
 wp_timezone_override_offset earlier, preferably as soon as the database is
 available. This allows the date_default_timezone_set function to get run,
 setting the local timezone properly early on.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9588#comment:17>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list