[wp-trac] [WordPress Trac] #48733: Problems with date after replacing date_i18n() with wp_date()

WordPress Trac noreply at wordpress.org
Wed Nov 20 07:32:26 UTC 2019


#48733: Problems with date after replacing date_i18n() with wp_date()
---------------------------+----------------------
 Reporter:  Guido07111975  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  closed
 Priority:  normal         |   Milestone:
Component:  Date/Time      |     Version:  5.3
 Severity:  normal         |  Resolution:  invalid
 Keywords:                 |     Focuses:
---------------------------+----------------------

Comment (by Rarst):

 > My example 1574121600 is a Unix timestamp, and without offset.. Am I
 right?

 ''If'' that timestamp produces the expected result with `date_i18n()` but
 ''not'' `wp_date()` then no, you are wrong and that ''is'' in fact a WP
 timestamp, not Unix one.

 I know this is horribly confusing, but `date_i18n()` had never worked with
 Unix timestamps and big part of `wp_date()` role is to move away from the
 horror of WP timestamps.

 Here is a quick way to illustrate with code:

 {{{#!php
 <?php

 var_dump(
         // this will be correct
         wp_date( DATE_RFC3339, time() ),

         // this will be wrong
         date_i18n( DATE_RFC3339, time() ),

         // this will be correct
         date_i18n( DATE_RFC3339, time() + ( HOUR_IN_SECONDS * get_option(
 'gmt_offset' ) ) ),
 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48733#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list