Give a model.created_at
I've been able to use:
<%="开发者_Go百科#{time_ago_in_words(model.created_at)} ago "%>
What is the helper to output something like
- Oct 8
- Sep 23
- Aug 31
- Jul 11
Bonus points, if it outputs like above, but for any records that were created today (not 24hrs ago but today). it shows the time, example:
- 4:31pm
- 1:20pm
- 9:31am
- Oct 8
- Sep 23
- Aug 31
- Jul 11
Thanks
How about a helper method like:
def formated_date(date)
if date > Time.now.beginning_of_day
return date.strftime("%l:%M%p")
end
date.strftime("%b %d")
end
精彩评论