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.
我从数据库中收到以下值,它是毫秒(微时间)值
1369057622.4679
我想在 PHP 中输出这个
3天前
基本上读取毫秒值并将其转换为相对日期字符串,任何人都可以提出一个简单的方法来做到这一点。
您可以执行以下操作:
$input = 1369057622.4679; $diff = floor(($input-time())/86400); // calculating the difference $result = abs($diff) . (abs($diff)==1 ? ' day ':' days ') . ($diff<=0 ? 'ago':'ahead'); // making the result. echo $result; // output: 1 day ago