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

time.getgm → new_time

Returns a new Time object representing time in UTC.

Example
t = Time.local(2000,1,1,20,15,1)   #=> 2000-01-01 20:15:01 -0600
t.gmt?                             #=> false
y = t.getgm                        #=> 2000-01-02 02:15:01 UTC
y.gmt?                             #=> true
t == y                             #=> true
See also #friday? #getlocal #floor #getutc also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1