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

后端 未结 6 943
眼角桃花
眼角桃花 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:26

    Choose what you want

     Date.parse('5-jan-2017').strftime('%B')
    

    Result:

    => "January"

    Date.parse('5-jan-2017').strftime('%b')
    

    Result:

    => "Jan"

    For most of your further date related questions, refer this link http://www.foragoodstrftime.com/

提交回复
热议问题