Jirapong Jirapong - 2 years ago 88
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 Source

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"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download