2012-12-02 50 views

回答

1
$dateposted = '2012-12-1 12:59:44'; 
$dateposted2 = '1354661156'; // time(); 

echo ceil((strtotime("now") - strtotime($dateposted))/3600); 
echo ceil((strtotime("now") - $dateposted2)/3600); 
+0

哇..這真的幫了我很多。但只有一個棘手的問題,你如何顯示36小時(相當於1天和12小時)?讓我們說$ dateposted ='2012-12-1 12:59:44';所以strtotime($ date_posted)?如果格式化時間如此,我會改變什麼? –

+0

只是把它放入strtime函數..檢查編輯 – vlcekmi3

+0

如果格式是從時間()?像$ dateposted = 1354661156;或= time(); ? –