Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Time#nsec

nsec → integer

Alias of #tv_nsec

Returns the number of nanoseconds in the subseconds part of self in the range (0..999_999_999); lower-order digits are truncated, not rounded:

Example
t = Time.now # => 2022-07-11 15:04:53.3219637 -0500
t.nsec       # => 321963700

Related: Time#subsec (returns exact subseconds).

Time#tv_nsec is an alias for Time#usec.

See also #tv_nsec #month #rfc2822 #monday? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0