2010-08-01 61 views
1
distance_of_time_in_words(strtotime(2010-08-07), strtotime(2010-08-01)) 

返回「6分鐘的distance_of_time_in_words瘋了!

$a = '2010-08-02 00:39:29' 
$b = '2010-08-01' 
distance_of_time_in_words($a, $b) 

回報 '不到一分鐘'

$a = '2010-08-02 00:39:29' 
$b = '2010-08-01 20:08:00' 
distance_of_time_in_words($a, $b) 

'不到一分鐘'

回報我不知道如果我去錯了在轉換中..它是否接受時間戳或日期? 謝謝

回答

0
// call 
distance_of_time_in_words(getUnixTimestamp(), getUnixTimestamp($bill->created_at)); 

// utility method 
public function getUnixTimestamp($datetime = null) 
{ 
    return date("U", (($datetime) ? strtotime($datetime) : time())); 
} 

希望這會幫助別人!

2

檢查它是source code它似乎需要時間戳(它在函數的開始做一些計算)。

+0

感謝指針Maerlyn,是的,它接受時間戳.. – Prasad 2010-08-02 03:34:15