3 ms·
irb(main):033:0> 20.years => 20 years # ?????? irb(main):030:0> 20.years.to_i => 631152000 # number of seconds in 20 year
by bodhi 17y ago
irb(main):033:0> 20.years
=> 20 years # ??????
irb(main):030:0> 20.years.to_i
=> 631152000 # number of seconds in 20 years
irb(main):026:0> 20.years.from_now
=> Sun Feb 10 10:14:11 +1100 2030 # AEDT
irb(main):027:0> 20.years.from_now.utc
=> Sat Feb 09 23:14:14 UTC 2030 # UTC/GMT
Ruby Time instances have a timezone, calling Time#utc returns the instance time converted from localtime -- or whatever timezone it is -- to UTC or Greenwich Mean Time. You are correct in that it shouldn't matter which one you use in this situation though.
- psadauskas 17y agoYour first one, commented with ??????, is an instance of a Duration object. It implements the #ago and #from_now methods, so that Integer objects aren't cluttered with methods that mean nothing to it. http://api.rubyonrails.org/classes/ActiveSupport/Duration.html http://api.rubyonrails.org/classes/ActiveSupport/Duration.ht...