I have a list that outputs like so:
This works fine, the output is correct:
<% @chat_feed.each do |item| %>
<%= item.created_at %>
<% end %>
Output:
2011-06-18 00:29:55 UTC
2011-06-18 00:30:01开发者_如何转开发 UTC
2011-06-18 00:30:05 UTC
But when I loop through like this, trying to format the datetime format, all the values show up the same. Why? Is this setting something?
<% @chat_feed.each do |item| %>
<%= item.created_at.strftime("%m/%d/%y %l:%d %p") %>
<% end %>
output
06/18/11 12:18 AM
06/18/11 12:18 AM
06/18/11 12:18 AM
Your format is incorrect. "12:18" is "Hour-of-day:day-of-month", because you've used %d
for minutes, when what you want is %M
(uppercase).
精彩评论