Forum: Ruby on Rails RE: help with date formats

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bharat A. (Guest)
on 2006-06-06 06:39
(Received via mailing list)
From: Josh K. <removed_email_address@domain.invalid>
> Subject: [Rails] help with date formats
> i have a datetime field in my database that i need broken up.
> i want to
> display the date and the time in separate places. i tried looking
> through the api, but couldn't find what i was looking for.

Take a look at strftime in the ruby std api documentation, it has a lot
of options for various kinds of formatting.
time = Time.now
   t.strftime("Printed on %m/%d/%Y")   #=> "Printed on 06/06/06"
   t.strftime("at %I:%M%p")            #=> "at 08:06AM"

Hope that helps,

Bharat
This topic is locked and can not be replied to.