[wp-trac] [WordPress Trac] #43493: with date format 'c', the_time() and get_the_time() print wrong time zone offset

WordPress Trac noreply at wordpress.org
Wed Mar 7 22:10:36 UTC 2018


#43493: with date format 'c', the_time() and get_the_time() print wrong time zone
offset
---------------------------+-----------------------------
 Reporter:  paulschreiber  |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Date/Time      |    Version:  trunk
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 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 to`false`.

 See related #43480.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43493>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list