Formatting Date Output Hash
The output from my hash is giving me the following date time:
开发者_如何学JAVA16 May 11 13:12:14 +0000
How do I go about formatting this into something sensible?
Thanks
I'll assume you are wanting this output in a view... First, you can create some formats:
# /config/locales/en.yml:
en:
date:
formats:
full: "%b %d, %Y"
time:
formats:
full: "%B %d, %Y at %I:%M%p"
Then you can display a datetime in a view using the l
method with specified format:
<%= l @something.updated_at, :format => :full %>
This would display something like the following:
May 16, 2011 at 01:12pm
More on the i18n formats
List of available directives
精彩评论