Here's the thing about Time
in Ruby. Time.now.to_f
gives you the number of seconds since the Epoch. More info about the Epoch is available on wikipedia
To get a difference between two Time
objects, you should just subtract them to get the difference
, as noted in the docs.
To get the difference between two of objects that hold the same time, but are of different UTC offsets (as seen in your question), simply use the utc_offset
method.
a = Time.now
b = Time.now.utc
difference = (b.utc_offset - a.utc_offset)/60/60
#=> 5