odie’s webmemory

Format the datetime using StrFTime

November 17, 2006 · 1 Comment

To format a datetime, use StrFTime. For example to output the date in the following format “11/16/2006 11:58PM”, do the following: nowDT.strftime(“%m/%d/%y %I:%M%p”). nowDT is your datetime variable.

See the php documentation for further information. This also works for ruby on rails.

Categories: rubyonrails

1 response so far ↓

  • 2006 Nov 16 « Make It Work // November 17, 2006 at 12:05 am | Reply

    [...] Generate Scaffold created a layout for my Entry Controller and the view for each action in the Entry Controller. They are ugly. Eventually I need to use a CSS. For now I modified the list view to not use a table, but intead to just print each blog entry in a paragraph. I formatted the blog entry’s datetime using the Strftime function. [...]

Leave a Comment