Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get today's date in Ruby 1.9.3?

Tags:

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

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?

like image 368
joslinm Avatar asked Mar 12 '13 16:03

joslinm


1 Answers

Did you require 'date' ?

> require 'date'  => true > Date.today  => #<Date: 2013-03-12 ((2456364j,0s,0n),+0s,2299161j)> 
like image 90
Intrepidd Avatar answered Sep 30 '22 18:09

Intrepidd