WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#42451 closed defect (bug)

Fix Wordpress UCT Time not correct issue — at Version 1

Reported by: taojing10 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8.3
Component: Date/Time Keywords: reporter-feedback
Focuses: Cc:

Description (last modified by dd32)

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.

Change History (1)

#1 @dd32
4 years ago

  • Component changed from General to Date/Time
  • Description modified (diff)
  • Keywords reporter-feedback added

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.

Note: See TracTickets for help on using tickets.