#43493 closed defect (bug) (duplicate)
with date format 'c', the_time() and get_the_time() print wrong time zone offset
Reported by: | paulschreiber | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Date/Time | Keywords: | |
Focuses: | Cc: |
Description
With the date format 'c'
, the_time()
and get_the_time()
print the wrong time zone offset. They print +00:00
, even though the time shown is in local time, not GMT/UTC.
Example (inside the loop):
var_dump( [ get_option( 'gmt_offset' ), get_option( 'timezone_string' ), get_the_time( 'c' ), get_post_time( 'c', false ), get_post_time( 'c', true ) ] );
Output:
array (size=5) 0 => float -5 1 => string 'America/New_York' (length=16) 2 => string '2018-01-09T15:02:17+00:00' (length=25) // get_the_time( 'c' ); offset wrong 3 => string '2018-01-09T15:02:17+00:00' (length=25) // get_post_time( 'c', false ); offset wrong 4 => string '2018-01-09T20:02:17+00:00' (length=25) // correct
Implementation
the_time()
calls get_the_time()
, which calls get_post_time()
with $gmt
set tofalse
.
See related #43480.
Change History (4)
#2
@
7 years ago
- Resolution set to duplicate
- Status changed from new to closed
Duplicate of #20973.
Yeah, this is duplicate. All of these come down to date_i18n()
call down the line, which is unable to process shorthand formats.
Forcing it to GMT doesn't as much make it correct as makes brokeness less relevant.
Note: See
TracTickets for help on using
tickets.
Related #20973