Skip to content

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

instance method

Time#gmt?

time.gmt? → true or false

Alias of #utc?

Returns true if time represents a time in UTC (GMT).

Example
t = Time.now                        #=> 2007-11-19 08:15:23 -0600
t.utc?                              #=> false
t = Time.gm(2000,"jan",1,20,15,1)   #=> 2000-01-01 20:15:01 UTC
t.utc?                              #=> true

t = Time.now                        #=> 2007-11-19 08:16:03 -0600
t.gmt?                              #=> false
t = Time.gm(2000,1,1,20,15,1)       #=> 2000-01-01 20:15:01 UTC
t.gmt?                              #=> true
See also #utc? #getutc #gmtime #getlocal also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0