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#getutc

getutc → new_time

Alias of #getgm

Returns a new Time object representing the value of self converted to the UTC timezone:

Example
local = Time.local(2000) # => 2000-01-01 00:00:00 -0600
local.utc?               # => false
utc = local.getutc       # => 2000-01-01 06:00:00 UTC
utc.utc?                 # => true
utc == local             # => true

Time#getgm is an alias for Time#getutc.

See also #getgm #getlocal #gmt? #gmtime also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0