Formatting of dates in a text_field

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}
2006-07-07 12:00:00

I would like to reformat it to something like
07/07/2006 12:00pm

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



Shai wrote:

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 M.

Bojan M.
Informatika Mihelac, Bojan M. s.p. |
-> tools, scripts, tricks from our code lab:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs