Greetings. I have more fields as datepickers on the page. I use get_field_objects () to load them on the page template as I need both name and label and value. My code looks like this:
<?php
$fields = get_field_objects();
if( $fields )
{
foreach( $fields as $field_name => $field )
{
$format_in = 'd/m/Y'; // the format your value is saved in (set in the field options)
$format_out = 'd. m. Y'; // the format you want to end up with
$date = DateTime::createFromFormat($format_in, $field['value']);
$date_now = new DateTime();
if ($date_now < $date) {
?>
<div class="col-md-6" id="<?php echo $field['name'] . '_text' ?>">
<p class="mb-2"><?php echo $field['label']; ?>: <?php echo $date->format( $format_out ); ?></p>
</div>
<?php
}
}
}
?>
I need to sort $ field [‘value’] to have the dates sorted on the page.
Thanks for any help.