Extract Month & Date From ACF Date & Time

Quick Summary

  • Pass the ACF Date Time Picker value from get_field() to strtotime(), then date() with M prints the short month and d the two-digit day.
  • Use a Return Format like Y-m-d H:i:s, because strtotime() reads slashed dates as month/day and misreads formats such as d/m/Y.
  • Use the code inside the loop, remove the //MONTH and //DATE labels that print on the page, and switch to date_i18n() for translated months.

Event listings often show the date as a small calendar badge, with the month abbreviation above the day number. If you store the event start in an Advanced Custom Fields (ACF) Date Time Picker field, this snippet pulls the month and the day out of it so you can style them separately.

Use it in a theme template inside the loop, because get_field() reads the field from the current post.

PHP
<?php
  $ev_date_time = get_field('start_ev_date_time');
  $eventDate = strtotime(get_field('start_ev_date_time'));
?> 

//MONTH
<?php echo date('M', $eventDate); ?>
//DATE
<?php echo date('d', $eventDate); ?>

How it works

  • get_field('start_ev_date_time') returns the field value as a string in the field’s Return Format, which you choose in the field settings (see ACF’s Date Time Picker documentation). Replace start_ev_date_time with your own field name.
  • strtotime() turns that string into a Unix timestamp.
  • date('M', $eventDate) prints the three-letter month, such as Apr, and date('d', $eventDate) prints the day with a leading zero, such as 05.
  • Other PHP date characters work the same way, for example F for the full month name or j for the day without a leading zero.

Gotchas

  • strtotime() can misread some formats. With slashes it assumes the American month/day order, so a Return Format like d/m/Y g:i a gives wrong dates or none at all. A format such as Y-m-d H:i:s is safe.
  • The //MONTH and //DATE labels sit outside the PHP tags, so they will be printed on the page. Remove them when you copy the code.
  • $ev_date_time isn’t used afterwards, so you can drop that line.
  • date() always prints English month names. On a site in another language, use date_i18n() with the same arguments.

If your theme shows events or dates from ACF fields, see my custom WordPress development services.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More