End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Time#tv_sec
time.tv_sec → int
time.c
View on GitHub ↗
static VALUE
time_to_i(VALUE time)
{
struct time_object *tobj;
GetTimeval(time, tobj);
return w2v(wdiv(tobj->timew, WINT2FIXWV(TIME_SCALE)));
}
Alias of #to_i
Returns the value of time as an integer number of seconds since the Epoch.
If time contains subsecond, they are truncated.
Example
t = Time.now #=> 2020-07-21 01:41:29.746012609 +0900 t.to_i #=> 1595263289