#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: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Date/Time | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
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)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Related #20973