Home › Forums › Add-ons › Repeater Field › Show future dates using date & time, repeater fields › Reply To: Show future dates using date & time, repeater fields
Solved! Thanks to James and a help ticket and this blog post: http://joshuaiz.com/words/ordering-events-by-advanced-custom-fields-date-time-picker-field/
First I changed the date&time field output to a unix timestamp, to do so just put a capital U under custom.
then add:
$eventTIME = get_sub_field('event_date_time');
$today = current_time('timestamp'); // Get current unix timestamp
if($eventTIME<$today) continue;
If the event date is smaller than today’s date it skips it.
However, all my pretty dates were now displaying as unix timestamps. I changed the code to display them to this:
<?php $start = get_sub_field('event_date_time'); echo date_i18n('F j, Y - g:i a', $start); ?>
And done!
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.