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

time + numeric → time

Adds some number of seconds (possibly including subsecond) to time and returns that value as a new Time object.

Example
t = Time.now         #=> 2020-07-20 22:14:43.170490982 +0900
t + (60 * 60 * 24)   #=> 2020-07-21 22:14:43.170490982 +0900
See also .zone_offset #- .xmlschema #<=> also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0