Home > OS >  Formatting the datein html.erb
Formatting the datein html.erb

Time:09-17

is it possible to format the date in my html file? Response I am receiving from item.starts_at

starts_at: '2018-01-10 07:28:00'. I would like to display this as Jan 10

CodePudding user response:

<%= item.starts_at.strftime('%b %d') %>

CodePudding user response:

I18n.l(Date.today, format: :short) is what you are looking for, Rails includes these localization formats, more details: https://github.com/rails/rails/blob/b2eb1d1c55a59fee1e6c4cba7030d8ceb524267c/activesupport/lib/active_support/locale/en.yml#L3

  • Related