如何确定 Ruby 中两个时间实例之间的天数?
> earlyTime = Time.at(123)
> laterTime = Time.now
> time_difference = laterTime - earlyTime
我想确定 time_difference
中的天数(我不担心天数的小数部分。四舍五入都可以)。
最佳答案
两次的差异以秒为单位。将它除以 24 小时内的秒数。
(t1 - t2).to_i / (24 * 60 * 60)
关于ruby - 两个时间实例之间的天数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9608116/