Opened 9 years ago
Closed 6 years ago
#35458 closed defect (bug) (wontfix)
current_date returns incorrect timestamp
Reported by: | Turn On Social | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Date/Time | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
'timestamp' functionality appears to be wrong.
current_time('timestamp') should always return the timestamp according to UTC. That's because a timestamp is defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970.
Therefore, producing this offset by x number of hours for local time is incorrect logic. If it's 1,452,598,896 seconds since the start of Unix time, this does not change depending on timezone - the number of seconds is the same (but may instead be displayed differently depending on timezone).
John mentioned this was so it could be used in date functions but when an incorrect timestamp is fed to a date function, it will display the date wrong (as the timestamp has been artificially manipulated).
Change History (3)
#1
@
9 years ago
- Component changed from General to Date/Time
- Keywords reporter-feedback added
- Version trunk deleted
#2
@
7 years ago
While there is no official name for it you had discovered what I call "WordPress timestamp". It is indeed consists of sum of Unix timestamp with timezone offset and is grossly incompatible with Unix time.
Multiple WordPress functions expect WordPress timestamp and produce invalid results if passed Unix timestamp, most prominently date_i18n()
, see #38771
This behavior is essentially set in stone, short of completely rewriting entirety of Date/Time component in core.
Thanks for the ticket. Can you provide a code example demonstrating the incorrect behaviour?