Skip to content

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

instance method

Time#gmtoff

utc_offset -> integer

Returns the offset in seconds between the timezones of UTC and self:

Example
Time.utc(2000, 1, 1).utc_offset   # => 0
Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.

Time#gmt_offset and Time#gmtoff are aliases for Time#utc_offset.

See also #gmtime #gmt_offset #gmt? #hash also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0