I'm looking for a way to use meta_query to filter out posts with a meta-key value of a date-time in m/d/Y g:i a
format.
The post-meta is being set by ACF (Advanced Custom Fields).
I want to maintain m/d/Y g:i a
formatting for output on the frontend, but also need to filter out posts with dates in the past.
I know that I can use Ymd
format, likeso:
$date_now = date('Y/m/d');
$args = [
'meta_query'=>[
'relation'=>'AND',
[
'key'=>'event_time',
'value'=>$date_now,
'compare'=>'>=',
'type'=>'DATE',
],
]
];
I also know that I can retrieve all posts and use a subsequent loop to discard the posts which don't meet requirements.
But is there a better way to do this? Thanks for reading.