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. if someone could please point me in the right direction to format dates, that would be great. thanks -- Posted via http://www.ruby-forum.com/.
Josh Kieschnick wrote:> 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. > > if someone could please point me in the right direction to format dates, > that would be great. thanksI am not sure if it''s the best solution, but I use strftime. http://www.ruby-doc.org/core/classes/Time.html#M000258 -- Posted via http://www.ruby-forum.com/.
From: Josh Kieschnick <jjkiesch@gmail.com>> 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