I've been working with a rails form all day and I was just randomly testing it and tried the date 25/12/2009 and it came up with a huge error.
It was at this point I realised that rails is set to american date mode (mm/dd/yyyy) instead of the UK style: dd/mm/yyyy.
How can I set rails to automatically deal with all dates in dd/mm/yyyy format?
If you're using @Chris Ballance's solution note that Rails now modifies the Date
class directly so you'll get an uninitialized constant ActiveSupport
error with the solution.
See: uninitialized constant ActiveSupport::CoreExtensions
The updated argument:
my_date_formats = { :default => '%d/%m/%Y' }
Time::DATE_FORMATS.merge!(my_date_formats)
Date::DATE_FORMATS.merge!(my_date_formats)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With