I am trying to output a formatted date picker field into my website. I am using the php code that is recommended on your site for the date picker field, but it seems to only output the current date.
ACF code
<?php
// get raw date
$date = get_field('date', false, false);
// make date object
$date = new DateTime($date);
?>
<p>Event start date: <?php echo $date->format('j M Y'); ?></p>
<?php
// increase by 1 day
$date->modify('+1 day');
?>
<p>Event end date: <?php echo $date->format('j M Y'); ?></p>
Here is the code on my site:
$eventDate = get_field('event-date, false, false');
$eventDate = new DateTime(the_field('event_date')):
<div class=”event-summary”>
`
<span class=”event-summary__month”><?php echo $eventDate->format(‘M’); ?></span>
<span class=”event-summary__day”><?php echo $eventDate->format(‘d’): ?></span>