[wp-trac] [WordPress Trac] #41782: Using date_query with 'before' in WP_Query returns wrong timezone
WordPress Trac
noreply at wordpress.org
Sat Sep 2 13:42:48 UTC 2017
#41782: Using date_query with 'before' in WP_Query returns wrong timezone
--------------------------+-----------------------------
Reporter: Biranit | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Date/Time | Version: 4.8.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Hi,
When using the date_query for WP_Query, to retrieve posts before a given
date, it appears the date is used as gmdate - which creates an unwanted
gap.
Example:
My site's timezone settings is UTC+3
I do a query with {{{'date_query' => array('before' => '2017-01-01
10:00:00')}}} then I get results from prior to 2017-01-01 07:00:00.
Looking at wp-includes/date.php, I can see you already suspected this may
be an issue:
{{{
if ( ! is_array( $datetime ) ) {
// @todo Timezone issues here possibly
return gmdate( 'Y-m-d H:i:s', strtotime( $datetime, $now ) );
}
}}}
So, yes... there are timezone issues there for sure :D
I tried various ways to sort this out, with no luck. Both our server and
wordpress options are correctly set up. So it's just these kind of queries
-- and revisions suffer similarly -- from a distortion of the actual date
to return.
Thank you,
Bira
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41782>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list