【发布时间】:2016-11-20 01:34:03
【问题描述】:
我想用 jquery timeago 创建动态 timeago 函数,但我可以用 php time() 来做,因为它对每个服务器都是一样的,我可以轻松处理它。但我听说不建议存储时间戳(我从 php time() 函数中获取)它将在 2038 年等非常高的数字。
我还观看了 facebook html 代码,我认为他们也使用时间戳,因为我看到了这个:
<abbr title="Sunday, July 01, 2016 at 12:24pm" data-utime="1468743808" class="timestamp livetimestamp">
<span class="timestampContent">about an hour ago</span></abbr>
data-utime就是他们存储timestamp的意思吗
【问题讨论】:
-
好像你在谈论 2038 年的问题:en.wikipedia.org/wiki/Year_2038_problem 本质上,时间戳将高于最大有符号 32 位整数值,但这应该没有问题,因为那么大多数(如果不是全部)机器将是 64 位的并且能够处理 64 位整数。我建议将时间存储为时间戳,它非常容易操作并且没有任何实际问题。
-
如果我将时间戳存储在varchar(100)上会有什么问题吗?
-
应该没问题,但 BIGINT 应该更适合时间戳。
-
@ebildude123 我想知道是什么原因让 BIGINT 比 varchar 更好?BIGINT 是 64bit 不是吗?
标签: php jquery time timestamp timeago