[wp-trac] [WordPress Trac] #42451: Fix Wordpress UCT Time not correct issue

WordPress Trac noreply at wordpress.org
Tue Nov 7 03:06:58 UTC 2017


#42451: Fix Wordpress UCT Time not correct issue
-------------------------------+------------------------------
 Reporter:  taojing10          |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Date/Time          |     Version:  4.8.3
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------
Changes (by dd32):

 * keywords:   => reporter-feedback
 * component:  General => Date/Time


Old description:

> in wp-includes/functions.php, look for
>
>                 case 'timestamp':
>                         return ( $gmt ) ? time() : time() + ( get_option(
> 'gmt_offset' ) * HOUR_IN_SECONDS );
> change to
>                 case 'timestamp':
>                         //return ( $gmt ) ? time() : time() + (
> get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
>                         return ( $gmt ) ? strtotime(gmdate('Y-m-d
> H:i:s')) : strtotime(gmdate('Y-m-d H:i:s')) + ( get_option( 'gmt_offset'
> ) * 3600 );
>
> This issue because of php timestamp function.

New description:

 in wp-includes/functions.php, look for
 {{{
 case 'timestamp':
         return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) *
 HOUR_IN_SECONDS );
 }}}
 change to
 {{{
 case 'timestamp':
         //return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' )
 * HOUR_IN_SECONDS );
         return ( $gmt ) ? strtotime(gmdate('Y-m-d H:i:s')) :
 strtotime(gmdate('Y-m-d H:i:s')) + ( get_option( 'gmt_offset' ) * 3600 );
 }}}
 This issue because of php timestamp function.

--

Comment:

 Hi @taojing10,

 Can you clarify what issues you are seeing are?

 `time()` is always expressed as a UTC offset, it's timezone independent.
 Theoretically, `gmdate()` should be returning the same date as `time()` is
 in your example here.

 I suspect the situation you're experiencing may be a mismatch between
 server timezones and your PHP configuration, but it's not clear from your
 report if this is indeed the issue you're experiencing.

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


More information about the wp-trac mailing list