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

utc → self

Alias of #gmtime

Returns self, converted to the UTC timezone:

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

Time#gmtime is an alias for Time#utc.

Related: Time#getutc (returns a new converted Time object).

See also #gmtime .utc #utc? #usec also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0