【问题标题】:How do I separate the Month, Day, and Year fields from Advanced Custom Fields datepicker into a individual spans or divs?如何将高级自定义字段日期选择器中的月、日和年字段分隔为单独的跨度或 div?
【发布时间】:2013-07-07 22:56:47
【问题描述】:

尝试为乐队主题构建一个简单的活动日历。只是想知道是否有一种简单的方法可以实现这一目标。我试图让它尽可能简单,所以我试图避免使用免费或高级插件。

我可以设置类似这样的样式: Screenshot

编辑:

<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>

有没有更好的方法来做到这一点?

【问题讨论】:

  • 对不起...它现在已链接。

标签: php jquery wordpress date datepicker


【解决方案1】:

我是这样做的:

$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

看看function.datedatetime.format

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

【讨论】:

  • 谢谢!无论如何将输出包装在一个跨度中并为每个单独的跨度添加一个类?
猜你喜欢
  • 1970-01-01
  • 2013-12-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-17
  • 2019-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多