Name of this month (Date.today.month as name)

I'm using Date.today.month to display the month number. Is there a command to get the month name, or do I need to make a case to get it?


Date::MONTHNAMES[Date.today.month] would give you "January". (You may need to require 'date' first).


You can also use I18n:

I18n.t("date.month_names") # [nil, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
I18n.t("date.abbr_month_names") # [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
I18n.t("date.month_names")[Date.today.month] # "December"
I18n.t("date.abbr_month_names")[Date.today.month] # "Dec"

You can use strftime:

Date.today.strftime("%B") # -> November

http://www.ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#strftime-method