Home › Forums › General Issues › Compare date field with current time in query › Reply To: Compare date field with current time in query
It is a date/time field Set to return/show in this format:
2021-01-23 12:01:54 | Y-m-d H:i:s
So my thinking goes, i need to first establish if an unpublished date have been set, and if it has compare it to the current time.
This is where im at right now: still not working as intended:
$unpublish = get_field('unpublish');
$current_time = date( 'Y-m-d H:i:s' );
if( ! empty($unpublish) ) {
array_push( $metaQuery, array(
'key' => 'unpublish',
'compare' => '>',
'value' => $current_time,
),
);
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.