Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#43493 closed defect (bug) (duplicate)

with date format 'c', the_time() and get_the_time() print wrong time zone offset

Reported by: paulschreiber's profile paulschreiber Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Date/Time Keywords:
Focuses: Cc:


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 )
] );


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

the_time() calls get_the_time(), which calls get_post_time() with $gmt set tofalse.

See related #43480.

Change History (4)

#2 @Rarst
6 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.

#3 @paulschreiber
6 years ago

Excellent! A duplicate of a bug from 2012. For which patches existed in 2014.

#4 @ocean90
6 years ago

  • Milestone Awaiting Review deleted
  • Version trunk deleted
Note: See TracTickets for help on using tickets.