Transforming Datetime into month, day and year?

I don't know for

June 14th, 2010

But if you want

June 14, 2010

Ref how do i get name of the month in ruby on Rails? or this

Just do

@date = Time.now
@date.strftime("%B %d, %Y")

And for suffix use following

@date.strftime("%B #{@date.day.ordinalize}, %Y") # >>> Gives `June 18th, 2010`

Time and date formats in rails:

Date

====

db:‘%Y-%m-%d’   2008-08-20

long_ordinal:‘&proc’      August 20th, 2008

long:‘%B %e, %Y’  August 20, 2008

rfc822:‘%e %b %Y’   20 Aug 2008

number:‘%Y%m%d’     20080820

short:‘%e %b’      20 Aug

DateTime

====

db:‘%Y-%m-%d’   2008-08-20 16:56:21

long_ordinal:‘&proc’      August 20th, 2008 16:56

long:‘%B %e, %Y’  August 20, 2008 16:56

rfc822:‘%e %b %Y’   Wed, 20 Aug 2008 16:56:21 -0600

number:‘%Y%m%d’     20080820165621

short:‘%e %b’      20 Aug 16:56

Time

====

db:‘%Y-%m-%d %H:%M:%S’         2008-08-20 16:56:21

long_ordinal:‘&proc’           August 20th, 2008 16:56

long:‘%B %d, %Y %H:%M’           August 20, 2008 16:56

rfc822:‘%a, %d %b %Y %H:%M:%S %z’  Wed, 20 Aug 2008 16:56:21 -0600

short:‘%d %b %H:%M’               20 Aug 16:56

number:‘%Y%m%d%H%M%S’              20080820165621

time:‘%H:%M’                     16:56

for example:

<%= news.created_at.strftime("%B %d, %Y %H:%M") %>

Thanks http://onrails.org/2008/08/20/what-are-all-the-rails-date-formats.html