#11672 closed defect (bug) (fixed)
current_time() does not correctly retrun localized time
Reported by: | hiromasa | Owned by: | nbachiyski |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 2.9 |
Component: | Date/Time | Keywords: | |
Focuses: | Cc: |
Description
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 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 echo date('Y-m-d H:i:s', current_time( 'timestamp' )); ?>
Change History (5)
Note: See
TracTickets for help on using
tickets.
See also #9588 #10940 #11672