To extract the month and year from your ACF date field (like 11 August 1989), you can do this:
To extract the month and year from your ACF date field (like 11 August 1989), you can do this:
================
To concatenate the month and year with a space (e.g., August 1989), just update your code like this:
<?php
$value = get_field("date"); // Example: "11 August 1989"
if ( $value ) {
$day = date('j', strtotime($value)); // Day (1–31)
$month = date('F', strtotime($value)); // Full month name
$year = date('Y', strtotime($value)); // 4-digit year
$month_year = $month . ' ' . $year; // Concatenated month and year
?>
<p class="date"><?php echo $day; ?></p>
<p class="month-year"><?php echo $month_year; ?></p>
<?php } ?>
Comments
Post a Comment