Rails display formatted date in words -


i have date in format 2014-04-05 gotten @post.date
want convert format "saturday apr 5" in view.
, if date today, want use format "today apr 6" have

<% if @post.date === date.today.strftime("%y-%m-%d") %>    <p> today month(short form) day(number) </p> <% else %>    <p> day(word) month(short form) day(number)  </p> <% end %> 

how go formatting dates?
in advance.

use this:

<% if @post.date === date.today %>    <%= @post.date.strftime("today %b %d") %> <% else %>    <%= @post.date.strftime("%a %b %d") %> <% end %> 

refer complete list of format directives available strftime.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -