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

time.sec → integer

Returns the second of the minute (0..60) for time.

Note: Seconds range from zero to 60 to allow the system to inject leap seconds. See en.wikipedia.org/wiki/Leap_second for further details.

Example
t = Time.now   #=> 2007-11-19 08:25:02 -0600
t.sec          #=> 2
See also #saturday? #strftime #round #subsec also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1