2013-05-28 33 views

回答

0

我已經解決了這個問題,

在我的模板

,我讓PHP

然後我添加此代碼,我從http://css-tricks.com/snippets/php/time-ago-function/

發現,但不使用功能,我不知道,但它給了我錯誤。只是直奔主 這樣的:

<?php 
$time = strtotime("{entry_date format="%d %F %Y"}"); 
    $periods = array("Second", "Minute", "Hour", "Day", "Week", "Month", "Year", "Decade"); 
    $lengths = array("60","60","24","7","4.35","12","10"); 

    $now = time(); 

     $difference  = $now - $time; 
     $tense   = "ago"; 

    for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { 
     $difference /= $lengths[$j]; 
    } 

    $difference = round($difference); 

    if($difference != 1) { 
     $periods[$j].= "s"; 
    } 

    echo "$difference $periods[$j] Ago"; 

?> 

可以幫助其他人具有相同的問題,因爲我

相關問題