Jirapong Jirapong - 6 months ago 10
Ruby Question

Is there an add_days in ruby datetime?

In C#, There is a method AddDays([number of days]) in DateTime class.

Is there any kind of method like this in ruby?

Answer

The Date class provides a + operator that does just that.

>> d = Date.today
=> #<Date: 4910149/2,0,2299161>
>> d.to_s
=> "2009-08-31"
>> (d+3).to_s
=> "2009-09-03"
>>