gpt4 book ai didi

ruby-on-rails - "Ago"Ruby/Rails 中的日期/时间函数

转载 作者:数据小太阳 更新时间:2023-10-29 06:18:37 26 4
gpt4 key购买 nike

我想知道 Rails 中是否有一种方法可以计算时间戳,例如 - 半分钟前、2 分钟前、1 天前等。类似于 Twitter 实时日期戳。

我想知道 Ruby/Rails 是否有内置的日期时间转换函数?

最佳答案

您可以使用:

10.minutes.ago
2.days.since

或者在您看来,您有 helper :

distance_of_time_in_words(from_time, to_time)
time_ago_in_words(from_time)

检查 the API了解详细信息和更多选项。

关于ruby-on-rails - "Ago"Ruby/Rails 中的日期/时间函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3278986/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com