[wp-trac] [WordPress Trac] #41782: Using date_query with 'before' in WP_Query returns wrong timezone
WordPress Trac
noreply at wordpress.org
Tue Nov 6 07:25:20 UTC 2018
#41782: Using date_query with 'before' in WP_Query returns wrong timezone
--------------------------+------------------------------
Reporter: Biranit | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Date/Time | Version: 4.8.1
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by jave.web):
The codex and reference states this
If you want a before date to be inclusive, include the time as well,
such as
'before' => '2013-02-28 23:59:59'
You would think your provided time is final, but no, it actually shifts
the time. This should NOT happen, your words should be the final words.
If you provide it separately year/month/day/hour/minute/second it is
(correctly) not altered (probably because of how the query is created).
The design problem is in {{{build_mysql_datetime()}}} method:
{{{
if ( ! is_array( $datetime ) ) {
// @todo Timezone issues here possibly
return gmdate( 'Y-m-d H:i:s', strtotime( $datetime, $now ) );
}
}}}
**Programmer rather added //@todo instead of just replacing {{{gmdate()}}}
with just {{{date()}}}, because {{{gmdate()}}} is affected by
{{{date_default_timezone_set()}}}, {{{date()}}} is not...**
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41782#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list