Doing Time Arithmetic : Time Calculation « Time « Ruby






Doing Time Arithmetic



day_one = Time.gm(1999, 12, 31)
day_two = Time.gm(2000, 1, 1)
day_two - day_one                           # => 86400.0
day_one - day_two                           # => -86400.0

 








Related examples in the same category

1.You can see the difference in two Time objects by subtracting them:
2.Add seconds and multiples of seconds to add to a time with +
3.Finding the Day of the Week
4.Is it a leap year