[wp-trac] [WordPress Trac] #18694: Improved date arguments for WP_Query
WordPress Trac
wp-trac at lists.automattic.com
Sun Sep 18 00:01:00 UTC 2011
#18694: Improved date arguments for WP_Query
--------------------------+------------------------------
Reporter: Viper007Bond | Owner: viper007bond
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.3
Severity: normal | Resolution:
Keywords: |
--------------------------+------------------------------
Comment (by Viper007Bond):
Nacin and I have been brainstorming a bit and here's some requirements and
potential argument formats that we've come up with.
{{{
'date_query' => array(
// Find posts between two dates
array(
'before' => '2011-09-17 16:40:23',
'after' => array(
'year' => 2011,
'month' => 8,
'day' => 12,
),
'inclusive' => true, // Including exactly the dates
),
// Find posts NOT between two dates
// due to before being less than after
array(
'before' => '2011-09-10',
'after' => '2011-09-15',
),
// Find all posts after 2PM on any day
array(
'time' => '14:00:00',
'compare' => '>',
),
// Find posts made during
// Nacin's crazy work hours
array(
'after' => '8:30:00',
'before' => '4:15:45',
// Is this even possible?
'dayofweek' => array( 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday' ),
),
),
}}}
The two range ones are easy -- basic MySQL.
The "after 2PM" example shouldn't be hard either. We're thinking you
covert the time to a number, like `4:32:45` would turn into `4.3245`. You
can't independently compare hours and minutes because that last example
would be greater than 30 and less than 15. You will have to merge hours,
minutes, and seconds into a single number you can compare.
I have no idea if the day of the week thing is possible, but it's an
interesting idea.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18694#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list