European date format

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:

:default => ‘%d/%m/%Y @ %H:%M: %p’ )
: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

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

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,

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

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?

LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.