I have setup a loop for WordPress which gets the date from a custom field (date picker) and passes it to a array. I need to determine the closest date in the future (upcoming date) from that array.
<?php
$today = current_time('m/d/Y');
$args=array(
'meta_key' => 'opening',
'orderby' => 'meta_value',
'order' => 'ASC',
'posts_per_page' => -1,
'post_type' => 'event',
);
$query = new WP_Query($args);
?>
<?php if($query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<?php
$date = DateTime::createFromFormat('Ymd', get_field('opening'));
$dates[] = $date->format('m/d/Y');
endwhile; endif; wp_reset_postdata();
print_r($dates);
?>
And pass it to javascript.
$('#tl').timeline({
startItem : '$resultOfUpcomingDateEvaluation',
});
Please advice, thanks for the time.