DateTime in Ruby 1.9.2

I'm migrating all my code from 1.8.7 to 1.9.2 and now when I run
something like:
DateTime.now.strftime("%Y%m")

I get the error: uninitialized constant Object::DateTime (NameError)

···

--
Posted via http://www.ruby-forum.com/.

I found out that it is necessary now to include
require 'date'

Mario Ruiz wrote in post #1028682:

···

I'm migrating all my code from 1.8.7 to 1.9.2 and now when I run
something like:
DateTime.now.strftime("%Y%m")

I get the error: uninitialized constant Object::DateTime (NameError)

--
Posted via http://www.ruby-forum.com/\.

I get that error in 1.8.7 as well unless I require date.rb:

$ ruby -v -e 'puts DateTime.now.strftime("%Y%m")'
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
-e:1: uninitialized constant DateTime (NameError)

$ ruby -v -rdate -e 'puts DateTime.now.strftime("%Y%m")'
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
201110

You probably lost your require statement somewhere along the way. Maybe
a new version of a third party library you use no longer requires it in
for you.

-Jeremy

···

On 10/26/2011 14:23, Mario Ruiz wrote:

I found out that it is necessary now to include
require 'date'