the_time() 无法正常工作,需要新手帮助


the_time() isn't working properly, need help for newbie


我想在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> 

如果您有其他解决方案可以单独包装日期,请帮助我。
提前感谢!

与其调用 the_time($format),不如使用 get_the_time($format)。这将返回值,而不是立即回显它。