[wp-trac] [WordPress Trac] #18694: Improved date arguments for WP_Query

WordPress Trac wp-trac at lists.automattic.com
Sun Sep 18 07:24:38 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 dd32):

 > I think I'm ditching string support. It's so much easier from a code
 perspective (hard to parse) and less ambiguous if you just pass an array
 of year, month, day, hour, minutes, and/or seconds.

 Less ambiguous for sure, however less flexible and will end up with people
 having to re-invent the wheel processing timestamps themselves.

 Something like this might be usable:
 {{{
 $a = array();
 list($a['year'], $a['month'],
 $a['day'],$a['hour'],$a['minute'],$a['second']) = explode(',',
 date('Y,m,d,H,i,s', strtotime('today')));
 //TODO: Filter out any items which are equal to 00 (h:i:s when only a date
 was specified)
 var_dump($a);
 }}}

 has the advantage you could use "6 hours ago" as well :)

 > and I think the existing meta_query arguments should be able to handle
 most (but not all) of that kind of stuff.

 Definitely agree, This can utilise date functions on a date column, meta
 fields are well, strings :)

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18694#comment:10>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list