Minus DateTime by day : Date Calculation « Date « Ruby






Minus DateTime by day

require 'date'
sent = DateTime.new(2006, 10, 4, 3, 15)
received = DateTime.new(2006, 10, 5, 16, 33)
elapsed = (received-sent) * 24
puts "#{elapsed.to_f} hours after."

 








Related examples in the same category

1.Subtract 61 days from a date:
2.Add and subtract six months using the >> and << methods.
3.Doing Date Arithmetic
4.Doing DateTime Arithmetic
5.Minus one DateTime from another
6.Move DateTime
7.leap year day
8.Counting the Days Since an Arbitrary Date
9.advent calendar
10.Remaining days