Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Time#gmt_offset

time.gmt_offset → integer

Alias of #gmtoff

Returns the offset in seconds between the timezone of time and UTC.

Example
t = Time.gm(2000,1,1,20,15,1)   #=> 2000-01-01 20:15:01 UTC
t.gmt_offset                    #=> 0
l = t.getlocal                  #=> 2000-01-01 14:15:01 -0600
l.gmt_offset                    #=> -21600
See also #gmtoff #hash #gmtime #hour also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0