I have a problem with date when saving into my sql with rails 3.
Into my environment.rb file i put Date::DATE_FORMATS[:default] =
“%d/%m/%Y”
i created a jquery calendar and into the text field the date is for
example 01/10/2010.
When i save, the date saved is 10/01/2010. the monthes and the days are
inversed.
into the log parameter is : “birthday”=>“01/10/2010”
and the update (db) : UPDATE profiles SET birthday = ‘2010-01-10’
…
I have a problem with date when saving into my sql with rails 3.
Into my environment.rb file i put Date::DATE_FORMATS[:default] =
“%d/%m/%Y”
i created a jquery calendar and into the text field the date is for
example 01/10/2010.
When i save, the date saved is 10/01/2010. the monthes and the days are
inversed.
into the log parameter is : “birthday”=>“01/10/2010”
and the update (db) : UPDATE profiles SET birthday = ‘2010-01-10’
…
format is saved as MM/DD/YYYY
Does anyone know how to make this work ?
Thank you.
I have also seen this problem. The DATE_FORMATS line seems to only tell
Rails that you want dates displayed this way. Mysql does whatever it
wants and ignores the instructions. There are a few ways that claim to
change this behavior on the web, but none have worked for me yet. I’d
love to see an answer to this problem. The inversed date is because
dates are shown that way in Europe and that is the way Mysql sees them.
I am running into the same issue. I have confirmed it works properly
on rails 3 and ree 1.8.7, but not on rails 3, ruby 1.9.2 (I am
wanting US formatted date strings)
[ruby-1.9.2] rails console
Loading development environment (Rails 3.0.0)
I have a problem with date when saving into my sql with rails 3.
Into my environment.rb file i put Date::DATE_FORMATS[:default] =
“%d/%m/%Y”
i created a jquery calendar and into the text field the date is for
example 01/10/2010.
When i save, the date saved is 10/01/2010. the monthes and the days are
inversed.
into the log parameter is : “birthday”=>“01/10/2010”
and the update (db) : UPDATE profiles SET birthday = ‘2010-01-10’
…
format is saved as MM/DD/YYYY
Does anyone know how to make this work ?
Thank you.
I have encountered the same issue using Ruby 1.9.2. However, when I
switch back to Ruby 1.8.7, the issue is no longer present. What version
of Ruby are you using? If you use 1.8.7, do you experience the same
behavior?