in my Rails 3.1, ruby 1.9.2 application, I’ve an Object ‘Post’ that has several fields such as id,created_at,updated_at,name,description…. In my view I want show post.created_at field filtered by date: I explain better:
In my view I’d want something such as:
but html must render something such as: 2011-30-06 and not 2011-30-06 11:04 am
in other words I want display only date and not hour, how can I do?
You should use strftime to format correctly the date (here’s the documentation)
It should look like this
<%= post.created_at.strftime("%Y-%M-%d) %>