End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Time#tv_sec
tv_sec
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 self as integer Epoch seconds; subseconds are truncated (not rounded):
Example
Time.utc(1970, 1, 1, 0, 0, 0).to_i # => 0 Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_i # => 0 Time.utc(1950, 1, 1, 0, 0, 0).to_i # => -631152000 Time.utc(1990, 1, 1, 0, 0, 0).to_i # => 631152000
Time#tv_sec is an alias for Time#to_i.