[wp-trac] [WordPress Trac] #59351: Add support for querying by an exact date with WP_Date_Query
WordPress Trac
noreply at wordpress.org
Fri Sep 15 22:49:11 UTC 2023
#59351: Add support for querying by an exact date with WP_Date_Query
-------------------------+------------------------------
Reporter: sean212 | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------+------------------------------
Comment (by Michi91):
From my perspective, the challenge will be to build the WHERE clause
depending on the input.
To stay with your example of {{{November 7th, 2010}}}, it should include
all posts on that day and not just {{{November 7th, 2010 00:00:00}}} or
{{{November 7th, 2010 23:59:59}}}? Another example: {{{November 7th, 2010
18:00}}} as input should include all possible seconds?
Right?
This is different from the {{{before}}} and {{{after}}} behavior, where
the statement is filled up to a minimum or maximum, depending on the
{{{inclusive}}} parameter.
strtotime / date_create will always add year, month, day, hour,minute,
seconds if they are missing. From my perspective it's hard to determine if
the hours, minute and seconds have been submitted by the user or by
strtotime/datetime when using a string as input.
Does anyone have a idea, how to solve this?
This is working btw:
{{{
// Query for posts after January 1st, 2013 OR exactly on November 7th,
2010
[
'date_query' => [
'relation' => 'OR',
[
'after' => 'January 1st, 2013',
],
[
'year' => '2010',
'month' => '11',
'day' => '7',
],
],
]
}}}
Maybe it shoud be nice to have {{{exact}}} but only with array as
parameter? This would still require a lot validation.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59351#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list