如何从wordpress的自定义字段中获取日期的日期和月份?

How to get only day and month of a date from custom field of wordpress?

我试图只获取 wordpress 自定义字段日期的日期和月份。我已经设法同时获得两者,但我需要在不同的 variables.Like: 27JUL 中显示月份和日期。这是我的代码。

<?php
   $time = strtotime( get_field( 'date' ) );
   $date = date( 'M d', $time );
   echo "$date";  
 ?>

这是您的代码:

<?php
   $time = strtotime( get_field( 'date' ) );
   echo '<span class="day">' . date( 'd', $time ) . '</span><span class="month">' . date( 'M', $time ) . '</span>';
 ?>

试试这个代码:

<?php
$date = "2012-01-05";
$time=strtotime($date);
$month=date("F",$time);
$date=date("d",$time);
?>

<span class="day"><?php echo $month; ?></span><span class="month"><?php echo $date; ?></span>