# Date format on text\_field when editing

**URL:** <https://www.ruby-forum.com/t/date-format-on-text-field-when-editing/140788>\
**Category:** Rails\
**Created:** [June 18, 2008, 3:32pm UTC](https://www.ruby-forum.com/t/date-format-on-text-field-when-editing/140788 "2008-06-18T15:32:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flaubert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/858c86/32.png) [@flaubert](https://www.ruby-forum.com/u/flaubert)\
**Post date:** [June 18, 2008, 3:32pm UTC](https://www.ruby-forum.com/t/date-format-on-text-field-when-editing/140788/1 "2008-06-18T15:32:46Z")

</div>

Hello all,

for weeks I have been looking for any code that can help me with this.

I type the date in a text\_field in the Brazilian format “dd/mm/yyyy”.  
Ok, everything works well, the data is stored in the table, great!

But, naturally, when I call editing, text\_fields shows me the date in  
ISO format.

There is some way to convert this date before this be shown?

The brazilian\_rails plugin does not work in this case.

---

<div class="post-metadata">

**Author:** ![flaubert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/858c86/32.png) [@flaubert](https://www.ruby-forum.com/u/flaubert)\
**Post date:** [June 18, 2008, 6:06pm UTC](https://www.ruby-forum.com/t/date-format-on-text-field-when-editing/140788/2 "2008-06-18T18:06:25Z")

</div>

Check your table and look type data for your date. change it tobe  
string, if you dont want change it tobe string, in your view, change to  
this code :

[options 1]

\<% @registration.date = @registration.date.strftime(‘$d/%m/%Y’)  
\<%= text\_field ‘registration’, ‘date’ %\>

[options 2]  
\<%= text\_field ‘registration’, ‘date’, :value=\>  
@registration.date.strftime(‘$d/%m/%Y’) %\>

WHY data value in text\_field is in ISO Format, because i am sure your  
data type is Date or Time, so that your text\_field will so date as like  
type data in table not as string that you wish to be shown in Brazillian  
format.

Sincerely,  
Reinhart  
[http://teapoci.blogspot.com](http://teapoci.blogspot.com)
