Opened 7 years ago
Closed 6 years ago
#42451 closed defect (bug) (worksforme)
Fix WordPress UTC Time not correct issue
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 )
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 (5)
#1
@
7 years ago
- Component changed from General to Date/Time
- Description modified (diff)
- Keywords reporter-feedback added
#2
@
7 years ago
- Summary changed from Fix Wordpress UCT Time not correct issue to Fix Wordpress UTC Time not correct issue
#3
@
7 years ago
- Summary changed from Fix Wordpress UTC Time not correct issue to Fix WordPress UTC Time not correct issue
I would like to note that feeding timestamps into any date function that takes "fuzzy" input should not be done, because significant portion of timestamps is ambiguous for PHP date parser and will crash.
On ticket overall — not clear what is it the issue is and what is it trying to fix.
Note: See
TracTickets for help on using
tickets.
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 astime()
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.