# European date format

**URL:** <https://www.ruby-forum.com/t/european-date-format/98675>\
**Category:** Rails\
**Created:** [July 17, 2006, 1:21pm UTC](https://www.ruby-forum.com/t/european-date-format/98675 "2006-07-17T13:21:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![remcoh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@remcoh](https://www.ruby-forum.com/u/remcoh)\
**Post date:** [July 17, 2006, 1:21pm UTC](https://www.ruby-forum.com/t/european-date-format/98675/1 "2006-07-17T13:21:43Z")

</div>

hi, overhere users go nuts if they have to enter the date in iso format,  
so i have to make my applications in such a way that not only dates are  
displayed in the “dd-mm-yyy” format but also can be entered in that way.

somewhere i found this code to put in the environment script:

ActiveSupport::CoreExtensions::Time::Conversions::DATE\_FORMATS.update(  
:default =\> ‘%d/%m/%Y @ %H:%M: %p’ )  
ActiveSupport::CoreExtensions:📅:Conversions::DATE\_FORMATS.update(  
:default =\> ‘%d/%m/%Y’ )

this works great for displaying dates, the only problem is i can’t input  
a new date anymore:

i tried:

- the date\_select control =\> doesn’t work anymore
- text\_field with input ‘dd-mm-yyyy’ =\>doesn’t work
- text\_field with input ‘yyyy-mm-dd’ =\>doesn’t work either ???

How should i handle this? there must be a lot of developers facing  
simular problems i guess

thanx remco

---

<div class="post-metadata">

**Author:** ![remcoh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@remcoh](https://www.ruby-forum.com/u/remcoh)\
**Post date:** [July 17, 2006, 5:39pm UTC](https://www.ruby-forum.com/t/european-date-format/98675/2 "2006-07-17T17:39:21Z")

</div>

Remco Hh wrote:

> simular problems i guess
> 
> thanx remco

Hi Remco, you can replace parsedate method so it would allow european  
format, for example:

require (‘parsedate’)  
module ParseDate  
class \<\< self  
alias\_method :old\_parsedate, :parsedate unless  
method\_defined?(:old\_parsedate)  
end

def self.parsedate(str)  
match = /(\d{1,2}).(\d{1,2}).(\d{2,4}).?/.match(str)  
return ParseDate.old\_parsedate(str) unless match  
[match[3].to\_i, match[2].to\_i, match[1].to\_i, nil, nil, nil, nil,  
nil]  
end  
end

–  
Bojan M.  
Informatika Mihelac, Bojan M. s.p. | [www.informatikamihelac.com](http://www.informatikamihelac.com)  
 → tools, scripts, tricks from our code lab: [http://source.mihelac.org](http://source.mihelac.org)

---

<div class="post-metadata">

**Author:** ![remcoh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@remcoh](https://www.ruby-forum.com/u/remcoh)\
**Post date:** [July 17, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/european-date-format/98675/3 "2006-07-17T19:35:47Z")

</div>

Remco Hh escribiÃ³:

> simular problems i guess
> 
> thanx remco

For display the dates I use a helper:

module ApplicationHelper  
def eu\_date(date)  
return date.strftime(“%d/%m/%Y”) unless date.nil?  
nil  
end  
end

* * *

LLama Gratis a cualquier PC del Mundo.  
Llamadas a fijos y móviles desde 1 céntimo por minuto.  
[http://es.voice.yahoo.com](http://es.voice.yahoo.com)
