Skip to content

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

instance method

Time#utc

time.utc → time

Alias of #gmtime

Converts time to UTC (GMT), modifying the receiver.

Example
t = Time.now   #=> 2007-11-19 08:18:31 -0600
t.gmt?         #=> false
t.gmtime       #=> 2007-11-19 14:18:31 UTC
t.gmt?         #=> true

t = Time.now   #=> 2007-11-19 08:18:51 -0600
t.utc?         #=> false
t.utc          #=> 2007-11-19 14:18:51 UTC
t.utc?         #=> true
See also #gmtime .utc #utc? #usec also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1