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

time.tv_sec → int

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
See also #to_i #tv_nsec #tv_usec #tuesday? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0