一直在挖掘文档,但无法找到是否有一个函数来计算
- <
- 小时/gh><
- 分钟/gh><
- 秒/gh>
作为独立于ruby日期时间戳的变量
是否有内置函数或必须自己计算?
从API文档中,查看distance_of_time_in_words
,我认为这是你正在寻找的。
def find_time
distance_of_time_in_words(Time.now, due_at)
end
这将计算从现在到due_at
时间戳的时间长度。您可以通过选项include_seconds = true
来显示秒