RailsGrunt

a noob working the ruby railroad.

to print out month, date, and day from created_at field

March 2nd, 2007

you can just do this in your view. for more information, check out the time class in the ruby api. basically if you would like to save time about a certain model/object, you can define ”:created_at, :timestamp, :null => false” in your migration file. doing this, you can print out various time formats like below.

<= yourvariable.created_at.strftime(“%b”)>

<= yourvariable.created_at.strftime(“%d”)>

<= yourvariable.created_at.strftime(“%a”)>

Sorry, comments are closed for this article.