Reputation: 56739
I need to pass a variable to my view with Time.now + @seconds in time format (i.e. 12pm + 3600 seconds = 1:00pm, which goes to the view).
Time.now + @seconds #seconds is a fixnum
doesn't work because "Time can't be coerced into Fixnum". How then can I generate this simple result?
Upvotes: 6
Views: 6243
Reputation: 2756
Today I learned that (1.second + DateTime.now) != (DateTime.now + 1.second)
to answer your question try using Time.now + @seconds.seconds
or Time.now + @seconds.to_i.seconds
Upvotes: 2
Reputation: 52348
Another example
DateTime.current + 20.seconds
=> Mon, 11 Jan 2021 18:06:04 +0000
Upvotes: 0
Reputation: 4580
Don't barbeque me if this is wrong now but back when I was doing Rails you would just say Time.now + @seconds.seconds
. Also @seconds.seconds.from_now
Upvotes: 9