# Formato Data nei textfield

**URL:** <https://www.ruby-forum.com/t/formato-data-nei-textfield/81948>\
**Category:** IT\
**Created:** [January 16, 2007, 2:11pm UTC](https://www.ruby-forum.com/t/formato-data-nei-textfield/81948 "2007-01-16T14:11:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![giovanni\_zangrillo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@giovanni\_zangrillo](https://www.ruby-forum.com/u/giovanni_zangrillo)\
**Post date:** [January 16, 2007, 2:11pm UTC](https://www.ruby-forum.com/t/formato-data-nei-textfield/81948/1 "2007-01-16T14:11:32Z")

</div>

Ciao a tutti, ho una textfield in una view. Il valore attuale Ã¨ preso  
dal DB MYSQL e visualizzato nel formato yyyy-mm-dd. Io vorrei che  
venisse visualizzato nel formato europeo dd-mm-yyyy. Su quale file di  
configurazione posso agire (?) Ho provato a mettere \<%= text\_field  
‘contactventure’, ‘INdate.strftime(european\_date)’, etc…, ma il metodo  
non Ã¨ riconosciuto (mentre se lo uso nel controller va bene). Qualcuno  
puÃ² aiutarmi (?) Grazie mille, Giovanni Zangrillo.

---

<div class="post-metadata">

**Author:** ![giovanni\_zangrillo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@giovanni\_zangrillo](https://www.ruby-forum.com/u/giovanni_zangrillo)\
**Post date:** [January 16, 2007, 2:20pm UTC](https://www.ruby-forum.com/t/formato-data-nei-textfield/81948/2 "2007-01-16T14:20:30Z")

</div>

Anch’io ho avuto il tuo stesso problema… l’ho risolto in modo semplice  
facendomi tornare la data e poi chiamando il metodo  
.strftime("%d/%m/%Y").  
Ciao, Piera

---

<div class="post-metadata">

**Author:** ![giovanni\_zangrillo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@giovanni\_zangrillo](https://www.ruby-forum.com/u/giovanni_zangrillo)\
**Post date:** [January 16, 2007, 8:33pm UTC](https://www.ruby-forum.com/t/formato-data-nei-textfield/81948/3 "2007-01-16T20:33:41Z")

</div>

stb wrote:

> se non ho capito male devi fare cosÃ¬
> 
> [il tuo campo data].year  
> [il tuo campo data].day  
> [il tuo campo data].month  
> …  
> e via dicendo, visto che ho giÃ affrontato il problema ti do anche  
> questo  
> pezzo di codice, ti produce una data nel formato “01 Apr '07” prendendo  
> le  
> abbreviazioni dei mesi e solo le ultime due cifre dell’ anno.  
> \<%= departure.day %\>  
> \<%= Date::ABBR\_MONTHNAMES[departure.month] %\>  
> \<%= departure.year %\>
> 
> ah se ti da errore che non trova il metodo (year,month ecc…) puÃ²  
> essere  
> che il tuo non Ã¨ un campo date, poco male basta fare cosÃ¬  
> [il tuo campo data].to\_date.year  
> …  
> …
> 
> Saluti Andrea
> 
> ----- Original Message -----  
> From: “giovanni zangrillo” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Sent: Tuesday, January 16, 2007 2:11 PM  
> Subject: [ruby-it] Formato Data nei textfield
> 
> > 
> 
> * * *

Ciao e grazie, perÃ² il problema sta qui:  
\<%= text\_field ‘contactventure’, ‘INdate.strftime(european\_date)’, etc  
%\>. Quando metto INdate come metodo nella text field ruby me la  
trasforma in stringa e quindi non accetta i metodi per le date. Ho  
provato a scrivere ‘INdate’.to\_date o ‘INdate.to\_date’ e mi dÃ l’errore  
di “nil object”, chissÃ perchÃ¨!..dovrei capire come fa ruby a convertire  
le date in stringhe e fargliele scrivere direttamente come dico io. Voi  
sapete se c’Ã¨ qualche file di configurazione nei vendor che si puÃ²  
modificare. Io una volta lo feci, ma non mi ricordo piÃ¹ quale Ã¨ il file.  
C’Ã¨ tipo conversions.rb sotto DATE e TIME in activesupport\core\_ext mi  
pare…

---

<div class="post-metadata">

**Author:** ![giovanni\_zangrillo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@giovanni\_zangrillo](https://www.ruby-forum.com/u/giovanni_zangrillo)\
**Post date:** [January 16, 2007, 2:59pm UTC](https://www.ruby-forum.com/t/formato-data-nei-textfield/81948/4 "2007-01-16T14:59:42Z")

</div>

se non ho capito male devi fare cosÃ¬

[il tuo campo data].year  
[il tuo campo data].day  
[il tuo campo data].month  
…  
e via dicendo, visto che ho giÃ affrontato il problema ti do anche  
questo  
pezzo di codice, ti produce una data nel formato “01 Apr '07” prendendo  
le  
abbreviazioni dei mesi e solo le ultime due cifre dell’ anno.  
\<%= departure.day %\>  
\<%= Date::ABBR\_MONTHNAMES[departure.month] %\>  
\<%= departure.year %\>

ah se ti da errore che non trova il metodo (year,month ecc…) puÃ²  
essere  
che il tuo non Ã¨ un campo date, poco male basta fare cosÃ¬  
[il tuo campo data].to\_date.year  
…  
…

Saluti Andrea

----- Original Message -----  
From: “giovanni zangrillo” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Tuesday, January 16, 2007 2:11 PM  
Subject: [ruby-it] Formato Data nei textfield

> 

* * *

---

<div class="post-metadata">

**Author:** ![giovanni\_zangrillo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@giovanni\_zangrillo](https://www.ruby-forum.com/u/giovanni_zangrillo)\
**Post date:** [January 16, 2007, 9:58pm UTC](https://www.ruby-forum.com/t/formato-data-nei-textfield/81948/5 "2007-01-16T21:58:33Z")

</div>

scusa ma 'INdate.strftime(european\_date) che linguaggio Ã¨?  
Rails? chiedo perchÃ¨ se Ã¨ rails basta togliere gli apici, con gli apici  
Ã¨  
ovvio che te lo prenda come una stringa e senza nemmeno espandere gli  
eventuali valori

----- Original Message -----  
From: “giovanni zangrillo” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Tuesday, January 16, 2007 8:33 PM  
Subject: [ruby-it] Re: Formato Data nei textfield

> > le  
> > …
> > 
> > >
> 
> le date in stringhe e fargliele scrivere direttamente come dico io. Voi  
> sapete se c’Ã¨ qualche file di configurazione nei vendor che si puÃ²  
> modificare. Io una volta lo feci, ma non mi ricordo piÃ¹ quale Ã¨ il file.  
> C’Ã¨ tipo conversions.rb sotto DATE e TIME in activesupport\core\_ext mi  
> pare…
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

* * *
