#44491 closed enhancement (fixed)
Date/time calculations should not depend on default UTC time zone
Reported by: | Rarst | Owned by: | |
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Date/Time | Keywords: | |
Focuses: | Cc: |
Description
At the moment WP explicitly sets default PHP time zone to UTC during core load. A lot of calculations in core depend on that being the case when they execute.
Unfortunately as a runtime setting this can be easily changed by extensions, and there are plenty out there that mess it up.
While we cannot stop setting time zone to UTC (which would be giant backwards compatibility break) we can and should make all calculations in core independent of this context.
Specific things that should be fixed or audited:
- no
date()
calls, onlygmdate()
; - no
strtotime()
calls on input with ambiguous time zone; - no
DateTime
instancing without explicit time zone.
Will work on a patch.
Change History (9)
#4
@
6 years ago
Looking at the current trunk version I see some uses of getdate()
which also uses the local time (same as date()
). See https://secure.php.net/manual/en/function.getdate.php
We should probably add this to the list and investigate it's usage and alternatives.
The only occurances of getdate()
is two instances in wp-admin/includes/class-pclzip.php
as far as I can see.
#5
@
6 years ago
I looked at getdate()
and the only use is indeed in third-party-ish code, so I think we can leave it alone for now.
#7
@
5 years ago
- Resolution set to fixed
- Status changed from new to closed
It seems the rest of it isn't friendly to a bulk change, since it's hard to scan if input format has a time zone or not.
Obviously I am writing new API functions as immune to the problem, and rest stuff will have to be just ongoing work.
Previously: #37440