[wp-trac] [WordPress Trac] #41782: Using date_query with 'before' in WP_Query returns wrong timezone
WordPress Trac
noreply at wordpress.org
Sun Sep 3 11:07:22 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 | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by birgire):
Glad to hear that worked for you.
Yes this was just a way around the problem.
After some tests I found out that the second input argument to
{{{strtotime()}}} does not always have effect.
It was reported long time ago here:
https://bugs.php.net/bug.php?id=18177
I did some testing and found out that it doesn't have effect on these
examples:
{{{
echo strtotime("1 January 2017" ) . PHP_EOL;
echo strtotime("1 January 2017", time() + 3600 ) . PHP_EOL;
echo strtotime("2017-01-01" ) . PHP_EOL;
echo strtotime("2017-01-01", time() + 3600 ) . PHP_EOL;
echo strtotime("2017-01-01 10:00:00" ) . PHP_EOL;
echo strtotime("2017-01-01 10:00:00", time() + 3600 ) . PHP_EOL;
}}}
as they all display all the same value, but it seems to have an effect for
'''relative''' dates, e.g.
{{{
echo strtotime("last week" ) . PHP_EOL;
echo strtotime("last week", time() + 3600 ) . PHP_EOL;
echo strtotime("-3 days" ) . PHP_EOL;
echo strtotime("-3 days", time() + 3600 ) . PHP_EOL;
}}}
I didn't find any mention of this here:
http://php.net/manual/en/function.strtotime.php
We notice that the fallback in build_mysql_datetime() uses:
{{{
strtotime( $datetime, $now )
}}}
where {{{$now}}} is {{{time() + get_option( 'gmt_offset' ) +
HOUR_IN_SECONDS}}}.
I think we should at least patch it to support the {{{Y:m:d H:i:s}}}
match.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41782#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list