Search code examples
ruby

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?


Solution

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

    Can also use Date::ABBR_MONTHNAMES[Date.today.month] which gives "Jan".