I'm trying to modify the format the date is displayed on my website, I followed this tutorial here: https://www.advancedcustomfields.com/resources/date-picker/
But, the date output is always the current date, not the date specified on the date picker.
Can you see what is wrong with this? thanks.
<?php
$loop = new WP_Query( array( 'post_type' => 'event', 'paged' => $paged ) );
if ( $loop->have_posts() ) : ?>
<ul>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
// get raw date
$date = get_field('event_date');
// make date object
$date = new DateTime($date);
?>
<li>
<a class="event__title" href="<?php the_permalink() ?>"><?php echo get_the_title(); ?></a>
<span class="event__location"><?php the_field('event_location'); ?></span>
<span class="event__date"><?php echo $date->format('j M Y'); ?></span>
<a href="<?php the_permalink ?>">
Read more >
</a>
</li>
<?php endwhile; ?>
</ul>
<?php
endif;
wp_reset_postdata();
?>