Need small help in converting date format in ruby

喜欢而已 提交于 2019-12-06 00:53:08

You can use Date::DATE_FORMATS to add a new customized format, and Integer.ordinalize to get the day ordinal:

Date::DATE_FORMATS[:month_ordinal] = lambda { |date| 
  date.strftime("%A #{date.day.ordinalize}, %B") 
}

>> Date.today.to_formatted_s(:month_ordinal)
=> "Monday 25th, June"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!