Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: PHP时间戳直到“几小时前”麻烦
如何制作一个 PHP 时间戳,只显示几个小时前的时间?例如显示 48 小时而不是 2 天前和 480 小时而不是 20 天前。
$dateposted = '2012-12-1 12:59:44'; $dateposted2 = '1354661156'; // time(); echo ceil((strtotime("now") - strtotime($dateposted))/3600); echo ceil((strtotime("now") - $dateposted2)/3600);