我用RVM安装了
ruby-1.8.6-p383.系统ruby是1.9.1_p378-1
使用ruby 1.8时,我从Date.today和DateTime.now得到了错误的日期.而Time.now是正确的:
irb(main):002:0> DateTime.now.to_s => "2126--1-10618T11:23:43+00:00" irb(main):004:0> Date.today.to_s => "2126--1-10618" irb(main):005:0> Time.now => Thu Jan 28 11:55:27 +0000 2010
如果我切换到ruby 1.9,一切都很好:
irb(main):003:0> DateTime.now.to_s => "2010-01-28T11:58:51+00:00" irb(main):004:0> Date.today.to_s => "2010-01-28" irb(main):005:0> Time.now => 2010-01-28 11:59:05 +0000
有关如何让DateTime在ruby 1.8中正常工作的任何建议都将非常感激!