【问题标题】:Formatting date output with Advanced custom fields in wordpress使用 wordpress 中的高级自定义字段格式化日期输出
【发布时间】:2013-07-30 16:33:28
【问题描述】:

我正在努力获得输出的日期(根本!)

我有以下内容,我希望输出日期为 2014 年 5 月 26 日

            <p><?php the_field('description'); ?></p>
        <?php $date = DateTime::createFromFormat('Ymd', get_field('when')); ?>
        <h2><?php echo $date->format('d-m-Y'); ?></p>

以上所有内容都在 wordpress 循环中 即使我将变量声明移到循环之外,它仍然不起作用。

谢谢

【问题讨论】:

    标签: wordpress advanced-custom-fields


    【解决方案1】:

    这会回显:

    <?php the_date('jS F Y'); ?>
    

    这会将值返回给$date var:

    <?php $date = get_the_date('jS F Y'); ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-25
      • 1970-01-01
      • 1970-01-01
      • 2016-06-10
      • 1970-01-01
      • 2012-08-10
      • 1970-01-01
      相关资源
      最近更新 更多