如何在Ruby 1.9.3中获取今天的日期? [英] How to get today's date in Ruby 1.9.3?

查看:90
本文介绍了如何在Ruby 1.9.3中获取今天的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ruby 1.9.3,当我执行 Date.today 时,出现 NoMethodError:undefined method today'for Date:Class`

I'm using Ruby 1.9.3, and when I execute Date.today, I get NoMethodError: undefined methodtoday' for Date:Class`

我对此非常困惑,因为它确实出现在文档。虽然我知道这是2.0的文档,但是我看到的答案可以追溯到在1.8.7中实施时。在1.9中将​​其删除吗?

I'm pretty confused about this since it does appear to be in the documentation. Though I know this is the documentation for 2.0, but I see answers ranging back to when it was implemented in 1.8.7. Was this removed in 1.9?

推荐答案

是否要求输入'日期'

> require 'date'
 => true
> Date.today
 => #<Date: 2013-03-12 ((2456364j,0s,0n),+0s,2299161j)>

这篇关于如何在Ruby 1.9.3中获取今天的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆