Quantcast
Channel: Question and Answer » meta-query
Viewing all articles
Browse latest Browse all 36

What format does the meta_query TIME type require?

$
0
0

As per title – what format does the TIME type in a meta_query require?

I have a couple of custom fields, date and time – the aim is to show posts dated today and in the future up to the hour before time.

'meta_query' => array(
    'relation' => 'AND',
    array(
        'key'       => 'date',
        'value'     => date('Y-m-d',strtotime("today")),
        'compare'   => '>=',
        'type'      => 'DATE'
    ),
    array(
        'key'       => 'time',
        'value'     => date('H:i', strtotime("now -1 hour")),
        'compare'   => '<=',
        'type'      => 'TIME'
    )
)

The date part of the query functions fine, but the time query doesn’t – I suspect something to do with the format.


Viewing all articles
Browse latest Browse all 36

Trending Articles