Skip to content

Instantly share code, notes, and snippets.

@mudge
Last active September 5, 2023 09:32
Show Gist options
  • Save mudge/5152839 to your computer and use it in GitHub Desktop.
Save mudge/5152839 to your computer and use it in GitHub Desktop.
Using date ordinals in Rails through an I18n time format.
# This goes in config/locales/en.rb (*not* en.yml)
{
:en => {
:time => {
:formats => {
:full => lambda { |time, _| "%H:%M | %A, #{time.day.ordinalize} %B %Y" }
}
}
}
}
<%= l(Time.now, :format => :full) %>
<!-- 14:50 | Wednesday, 13th March 2013 -->
@letmein
Copy link

letmein commented Jun 3, 2021

Thanks for sharing it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment