How do I separate the Month, Day, and Year fields from Advanced Custom Fields datepicker into a individual spans or divs?

Trying to build a simple event calendar for a band theme. Just wondering if there’s a simple way to achieve this. I’m trying to make it as simple as possible, so I was trying to avoid using a free, or premium plugin.

Something I can style similar to this:
Screenshot

Read More

Edit:

<span class="show_day">
<?php $date = new DateTime(get_field('show_date'));
echo $date->format('d'); ?></span>
<span class="show_month"><?php $date = new DateTime(get_field('show_date'));
echo $date->format('F'); ?></span>

Is there a better way to do this?

Related posts

Leave a Reply

1 comment

  1. I did it this way:

    $date = new DateTime(get_field('date_field'));
    echo $date->format('d F'); // should print 07 August
    echo $date->format('h:i A'); // should print 09:30 PM
    

    Have a look at function.date and datetime.format.

    <span class="date"><?php echo $date->format('d F'); ?></span>
    <span class="time"><?php echo $date->format('h:i A'); ?></span>