Add seconds and multiples of seconds to add to a time with + : Time Calculation « Time « Ruby






Add seconds and multiples of seconds to add to a time with +


stop = Time.local( 2007, "jan", 30, 1, 15, 20 )
stop.inspect 

# Add a minute (60 seconds)
stop + 60 

# Add an hour (60*60)
stop + 60*60 

# Add three hours (60*60*3)
stop + 60*60*3 

# Add a day (60*60*24)
stop + 60*60*24 

 








Related examples in the same category

1.You can see the difference in two Time objects by subtracting them:
2.Doing Time Arithmetic
3.Finding the Day of the Week
4.Is it a leap year