#38642 closed defect (bug) (invalid)
current_time('mysql') and current_time('Y-m-d H:i:s') are returning different values
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.6.1 |
Component: | Date/Time | Keywords: | |
Focuses: | Cc: |
Description
current_time('mysql') is returning the local time correctly but current_time('Y-m-d H:i:s') is not.
Maybe default case in current_time() should be using gmdate() instead of date()?
Change History (3)
#2
@
8 years ago
- Resolution set to invalid
- Status changed from new to closed
Hi @dd32! Thanks for the prompt reply!
WordPress timezone is Asia/Singapore
PHP timezone is UTC
The problem actually happens on staging sever. I tried setting my local machine to UTC (default was Asia/Singapore), and current_time('mysql') and current_time('Y-m-d H:i:s') are returning the same value.
Think you right that the discrepancy is caused by some plugin. Or maybe it's some other server settings.
Sorry that I reported a false positive. I'll update here if I find out more info.
Note: See
TracTickets for help on using
tickets.
Hi @yeetien and welcome back to Trac.
WordPress operates with it's internal default timezone set to UTC, so under normal situations
date()
,gmdate()
andtime()
should all be returning the same timezone data - UTC (See #10940)In your case, it sounds like the default date timezone is set to something other than UTC, most likely because a plugin is incorrectly calling
date_default_timezone_set()
, which would result in the scenario you're reporting.Now that being said, I see no reason why this function is using both
gmdate()
anddate()
, but even fixing this you're likely to other dates being off elsewhere in WordPress wheredate()
is used in the expectation that it's been set to UTC.What timezone do you have WordPress set to? What about the PHP default timezone? Do you still experience it without plugins and using a default theme?