views:

25

answers:

2

Hi I have "Date.today + 2.days" I need to format it using .strftime, but with the "+2.days" it doesn't recognize that method.Any ideas?

A: 

I don't see a problem, worked fine for me.

(Date.today + 2.days).strftime
#=> "2010-07-18"
Karl
thanks I did something dumb and forgot to put parentheses around
looloobs
+1  A: 

Those nice helpers don't come with a vanilla ruby install. You need the activesupport gem (part of Ruby on Rails).

$ gem install activesupport

$ irb
ruby-1.8.7-p249 > require 'rubygems'
 => true 
ruby-1.8.7-p249 > require 'active_support'
 => true 
ruby-1.8.7-p249 > Date.today
 => Fri, 16 Jul 2010 
ruby-1.8.7-p249 > Date.today + 2.days
 => Sun, 18 Jul 2010 
bjg