how do I get name of the month in ruby on Rails?

后端 未结 6 952
眼角桃花
眼角桃花 2021-02-05 00:12

so i create in my view:

<%=date=Date.today%>

How do i get the name of the month out of the date? I was trying to do sth like



        
6条回答
  •  无人共我
    2021-02-05 00:20

    If you want a localized month name, try:

    I18n.t('date.month_names')[date.month]
    

    Example:

    I18n.t('date.month_names')[12] #=> "Dezembro"
    

提交回复
热议问题