0

I have some problem with comparing dates. I need to compare more than DateTime.now or record.updated_at for 7 days. I try do something like that: DateTime.now - record.updated_at but have result as that 143587.77856945992 or (14358777856939/8640000000000). I dont understand what is that. Maybee need convert to Time format or something else? Thanks

4

2 回答 2

1

如果你想要的话,那么你可以使用 distance_of_time_in_words

于 2013-07-05T13:59:15.270 回答
1

利用:

((DateTime.now - record.updated_at) * 24 * 60 * 60).to_i

获取秒数

(DateTime.now - record.updated_at).to_i

获得天数(显然......)

于 2013-07-05T14:09:16.910 回答