=> Fri Feb 01 00:00:00 +0000 2008
>> Date.new( 2008, 2, 1 ).to_time.advance( :months => 1 )
=> Sat Mar 01 00:00:00 +0000 2008
>> Date.new( 2008, 1, 1 ).to_time + 1.month
=> Thu Jan 31 00:00:00 +0000 2008
=> Thu Jan 31 00:00:00 +0000 2008
Extracted from here:
http://roninonrails.blogspot.com/2008/01/beware-of-rails-date-arithmetic.html
No comments:
Post a Comment