Reputation: 689
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
Upvotes: 0
Views: 52
Reputation: 3034
Use:
((DateTime.now - record.updated_at) * 24 * 60 * 60).to_i
to get the number of seconds
(DateTime.now - record.updated_at).to_i
to get the number of days (obviously...)
Upvotes: 1
Reputation: 1071
If you want in words then you can use distance_of_time_in_words
Upvotes: 1