[wp-trac] [WordPress Trac] #36309: Timezone issue in WP_Date_Query->build_mysql_datetime
WordPress Trac
noreply at wordpress.org
Wed Mar 23 15:57:02 UTC 2016
#36309: Timezone issue in WP_Date_Query->build_mysql_datetime
-------------------------+-----------------------------
Reporter: fad.lee | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 4.4.2
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
Currently build_mysql_datetime function in WP_Date_Query using gmdate to
generate SQL datetime.
{{{#!php
<?php
if ( ! is_array( $datetime ) ) {
// @todo Timezone issues here possibly
return gmdate( 'Y-m-d H:i:s', strtotime( $datetime, $now ) );
}
}}}
That leads to unexpected result in my use case.
My timezone is GMT -7.
When I want to get posts before the current post (e.g. post_date
2015-12-30 14:00:02), the query get posts before 2015-12-30 07:00:02.
That not what I want.
I'm trying to use GMT with get_post_time function, but the query get posts
before 00:00:02. Farther from what I want.
I think this function not need to change date timezone with gmdate. Just
use datetime as is with date function.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36309>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list