From: Todd Benson Date: 2008-09-15T00:30:25+09:00 Subject: Re: Getting current date On Fri, Sep 12, 2008 at 1:13 PM, Todd Benson wrote: > On Fri, Sep 12, 2008 at 12:13 PM, laredotornado > wrote: >> On Sep 11, 9:38 pm, "DanDiebolt.exe" wrote: >>> [Note: parts of this message were removed to make it a legal post.] >>> >>> irb(main):005:0> Date.today.to_s >>> => "2008-09-11" >>> >>> Seehttp://www.ruby-doc.org/core/classes/Date.html >> >> Thanks for this info and the link. I couldn't find this on the linked >> page, but what is an expression to get the current date minus one >> month, in the same format as above? >> >> - Dave > > In IRB... > > require 'date' > => true > (Date.today << 1).to_s > => 2008-8-12 > #Be prepared for edge cases... > (Date.new(2008-3-31) << 1).to_s > => 2008-2-29 That was, of course supposed to be (Date.new(2008, 3, 31) << 1).to_s, _not_ Date.new(2008-3-31). Note that the method is leap-year aware. Todd