[wp-trac] [WordPress Trac] #48923: Permalink Date is GMT Regardless of Time Zone Setting
WordPress Trac
noreply at wordpress.org
Mon Dec 9 21:43:02 UTC 2019
#48923: Permalink Date is GMT Regardless of Time Zone Setting
--------------------------+-----------------------------
Reporter: achmafooma | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Permalinks | Version: 5.3
Severity: major | Keywords:
Focuses: |
--------------------------+-----------------------------
The date in the WP permalinks is created from a GMT date (see link-
template.php):
{{{
$date = explode( ' ', gmdate( 'Y m d H i s', $unixtime ) );
}}}
This results in a mismatch if a post's local and GMT dates are a different
day.
For example, I have a post on my site with a 'post_date' of '2014-05-07
23:57:56' (US Eastern) and a "post_date_gmt" of "2014-05-08 03:57:56".
WordPress sets the permalinks with /2014/05/08/(slug) even though it
should be /2014/05/07/(slug).
As a result, attempting to visit the page results in a 404 error...because
the page query ends up asking for a post on /2014/05/08:
{{{
SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND (
( YEAR( wp_posts.post_date ) = 2014 AND MONTH( wp_posts.post_date ) = 5
AND DAYOFMONTH( wp_posts.post_date ) = 8 )
) AND wp_et_4_posts.post_name = '((REDACTED))' AND wp_posts.post_type =
'post' ORDER BY wp_posts.post_date DESC
}}}
Note that the WP query is checking post_date (not post_gmt_date) even
though the permalink was formed using a GMT date.
The preferable fix (in my opinion) is to use local date for both creating
and parsing permalinks including the post date...but it would also be
acceptable to make them both based on GMT. I think the most important
thing is that they match and not throw 404s.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48923>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list