[wp-trac] [WordPress Trac] #11672: current_time() does not correctly retrun localized time

WordPress Trac wp-trac at lists.automattic.com
Wed Dec 30 15:14:40 UTC 2009


#11672: current_time() does not correctly retrun localized time
--------------------------+-------------------------------------------------
 Reporter:  hiromasa      |       Owner:  nbachiyski
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  General       |     Version:  2.9       
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
 When you set you set timezone using a city name, current_time() function
 in functions.php does not return correct local time.

 ==== Cause: ====

 When you get gmt_offset(), the wp_timezone_override_offset() hook offsets
 the timezone again after date_default_timezone_set sets the timezone (this
 happens only when timezone_string exists).

 ==== Example 1: ====

 Your timezone is set to "Tokyo" (UTC+9), using the city name. wp_options
 will contain:
 {{{
 timezone_string Asia/Tokyo
 gmt_offset      ''
 }}}
 Code below will incorrectly retun UTC+9+9.
 {{{
 #!php
 <?php echo date('Y-m-d H:i:s', current_time( 'timestamp' )); ?>
 }}}
 ==== Example 2: ====
 Your timezone is set to "UTC+9" (WordPress 2.9.1 RC1). wp_options will
 contain:

 {{{
 timezone_string ''
 gmt_offset      9
 }}}
 Code below will correctly retun UTC+9.
 {{{
 #!php
 <?php echo date('Y-m-d H:i:s', current_time( 'timestamp' )); ?>
  }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11672>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list