End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Time#sec
time.sec → integer
time.c
View on GitHub ↗
static VALUE
time_sec(VALUE time)
{
struct time_object *tobj;
GetTimeval(time, tobj);
MAKE_TM(time, tobj);
return INT2FIX(tobj->vtm.sec);
}
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