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

time.inspect → string

Returns a detailed string representing time. Unlike to_s, preserves subsecond in the representation for easier debugging.

Example
t = Time.now
t.inspect                             #=> "2012-11-10 18:16:12.261257655 +0100"
t.strftime "%Y-%m-%d %H:%M:%S.%N %z"  #=> "2012-11-10 18:16:12.261257655 +0100"

t.utc.inspect                          #=> "2012-11-10 17:16:12.261257655 UTC"
t.strftime "%Y-%m-%d %H:%M:%S.%N UTC"  #=> "2012-11-10 17:16:12.261257655 UTC"
See also #httpdate #isdst #hour #iso8601 also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0