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

Popular posts from this blog

Get Post Data From Simple Post custom shortcode

Top 20 Beautiful Pen For Writing

Fatal error: Maximum execution time of 300 seconds exceeded in C:\xampp\phpMyAdmin\libraries\classes\Dbi\DbiMysqli.php on line 199