2012-06-28 47 views
2


我想包個月,日和年分別裏面的div和 我試着這樣做the_time()無法正常工作,需要幫​​助新手

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> 

如果你有另一個解決方案分別包裝日期請幫助我。
Thnx提前!

+0

您正在使用'printf'wrong。請查看[它的文檔](http://php.net/printf)。 – Carsten

回答

2

而不是調用the_time($格式),使用get_the_time($format)。這會返回值,而不是立即回顯。