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

前端 未结 6 943
南笙
南笙 2020-12-12 16:46

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?

6条回答
  •  庸人自扰
    2020-12-12 17:23

    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

提交回复
热议问题