【问题标题】:the_time() isn't working properly, need help for newbiethe_time() 无法正常工作,需要新手帮助
【发布时间】:2012-06-28 00:14:57
【问题描述】:


我想在 div 中分别包装月、日和年 我试过这样做

function posted_on_main_page() {
    $format= '<div class="posted-date">
                  <div class="posted-month">%1$s</div>
                  <div class="posted-day">%2$s</div>
                  <div class="posted-year">%3$s</div>
              </div>';
    $month = the_time('M');
    $date = the_time('j');
    $year = the_time('Y');
    printf($format, $month, $date, $year);

}

但由于某些原因,当我检查元素时,它会在所有内容之前显示日期

Jun272012<div class="posted-date">
              <div class="posted-month"></div>
              <div class="posted-day"></div>
              <div class="posted-year"></div>
         </div> 

如果您有另一种单独包装日期的解决方案,请帮助我。
提前谢谢!

【问题讨论】:

标签: php wordpress date


【解决方案1】:

不要调用 the_time($format),而是使用 get_the_time($format)。这会返回值,而不是立即回显它。

【讨论】:

    猜你喜欢
    • 2015-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 1970-01-01
    • 2015-02-18
    相关资源
    最近更新 更多