Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Time#gmt_offset

() -> ::Integer
gmt_offset

Alias of #gmtoff

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.
See also #gmtoff #hash #gmtime #hour also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0