When displaying a date field using a text_field object, is it possible
to specify how the date will be formatted?
<%= text_field ''item'', ''created_at'',
{:class=>"text-input", :size=>18,
:disabled=> true}
produces
2006-07-07 12:00:00
I would like to reformat it to something like
07/07/2006 12:00pm
--
Posted via http://www.ruby-forum.com/.
try x.strftime("%M/%d/%Y %h:%mpm")
where x is the date that is recievied.
any object from the Date/Time class can be modified this way.
check out
http://rubycentral.com/book/ref_c_time.html#Time.strftime
cheers,
shai
--
Posted via http://www.ruby-forum.com/.
Shai wrote:> try x.strftime("%M/%d/%Y %h:%mpm") > where x is the date that is recievied. > any object from the Date/Time class can be modified this way. > check out > > http://rubycentral.com/book/ref_c_time.html#Time.strftime > > cheers, > > shai >But check parsedate method to see if your format would be parsed back to proper date/time object once the form is submitted. best regards, Bojan Mihelac -- Bojan Mihelac Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com -> tools, scripts, tricks from our code lab: http://source.mihelac.org