Hello, 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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yannick Yanikos wrote:> Hello, > > 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. Bob <bsm2th-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yannick Yanikos wrote:> Hello, > > 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.Is this supposed to be 1 October or 10 January?> 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...so it''s saving to the DB as 10 January. Is that what you want, or do you want 1 October?> > Does anyone know how to make this work ? > > Thank you.Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser wrote:> Yannick Yanikos wrote: >> Hello, >> >> 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. > > Is this supposed to be 1 October or 10 January? > >> 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 > > ...so it''s saving to the DB as 10 January. Is that what you want, or do > you want 1 October? > >> >> Does anyone know how to make this work ? >> >> Thank you. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.orgIt seems to save correctly, just the display is wrong. In the US, 1/10/69 should be jan 10,1969, but after the save, it displays as 10/1/69 Bob -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yannick Yanikos wrote:> Hello, > > 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? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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)>> Offer.last.update_attributes(:publish_start => ''31/10/10'')=> true>> Offer.last.update_attributes(:publish_start => ''10/31/10'')=> false>> exit[ree-1.8.7] rails console Loading development environment (Rails 3.0.0)>> Offer.last.update_attributes(:publish_start => ''31/10/10'')=> false>> Offer.last.update_attributes(:publish_start => ''10/31/10'')=> true On Oct 9, 10:42 pm, Scott Griffin <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Yannick Yanikos wrote: > > Hello, > > > 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? > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It appears this is the issue. http://slightlycoded.com/blog/ruby-1-9-date-problems What is the preferred way to fix this in ruby 1.9 and rails? On Oct 10, 12:43 pm, johne <john.ebe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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) > > >> Offer.last.update_attributes(:publish_start => ''31/10/10'') > => true > >> Offer.last.update_attributes(:publish_start => ''10/31/10'') > => false > >> exit > > [ree-1.8.7] rails console > Loading development environment (Rails 3.0.0)>> Offer.last.update_attributes(:publish_start => ''31/10/10'') > => false > >> Offer.last.update_attributes(:publish_start => ''10/31/10'') > > => true > > On Oct 9, 10:42 pm, Scott Griffin <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > > > Yannick Yanikos wrote: > > > Hello, > > > > 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? > > -- > > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Found a plugin which aims to address localization and delocalization, but may be useful for this problem: http://github.com/clemens/delocalize On Oct 12, 8:02 am, johne <john.ebe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It appears this is the issue. > > http://slightlycoded.com/blog/ruby-1-9-date-problems > > What is the preferred way to fix this in ruby 1.9 and rails? > > On Oct 10, 12:43 pm, johne <john.ebe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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 formatteddatestrings) > > > [ruby-1.9.2] rails console > > Loading development environment (Rails 3.0.0) > > > >> Offer.last.update_attributes(:publish_start => ''31/10/10'') > > => true > > >> Offer.last.update_attributes(:publish_start => ''10/31/10'') > > => false > > >> exit > > > [ree-1.8.7] rails console > > Loading development environment (Rails 3.0.0)>> Offer.last.update_attributes(:publish_start => ''31/10/10'') > > => false > > >> Offer.last.update_attributes(:publish_start => ''10/31/10'') > > > => true > > > On Oct 9, 10:42 pm, Scott Griffin <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > > Yannick Yanikos wrote: > > > > Hello, > > > > > I have a problem withdatewhen saving into my sql with rails 3. > > > > > Into my environment.rb file i putDate::DATE_FORMATS[:default] > > > > "%d/%m/%Y" > > > > > i created a jquery calendar and into the text field thedateis for > > > > example 01/10/2010. > > > > When i save, thedatesaved 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? > > > -- > > > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You can try to personalize you jQuery datepicker as follows: [code] $("#project_formatted_start_date").datepicker({ altField: ''#project_formatted_start_date'',altFormat: ''yy-mm-dd''}); [/code] See jQuery API for datepicker for more details. On Oct 10, 9:43 pm, johne <john.ebe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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) > > >> Offer.last.update_attributes(:publish_start => ''31/10/10'') > => true > >> Offer.last.update_attributes(:publish_start => ''10/31/10'') > => false > >> exit > > [ree-1.8.7] rails console > Loading development environment (Rails 3.0.0)>> Offer.last.update_attributes(:publish_start => ''31/10/10'') > => false > >> Offer.last.update_attributes(:publish_start => ''10/31/10'') > > => true > > On Oct 9, 10:42 pm, Scott Griffin <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > Yannick Yanikos wrote: > > > Hello, > > > > 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? > > -- > > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
This has to do with how ruby 1.9.x changed the default Date.parse see this sample script: require ''time'' require ''date'' r = Date.parse("10/1/2010") puts r.strftime("%a %d %B %Y") ruby-1.9.2-p0 => Sun 10 January 2010 ruby-1.8.7-p302 => Fri 01 October 2010 One solution for Ruby 1.9.2 would be to redefine Date.parse as: class Date def self.parse(input) Date.strptime(input, "%m/%d/%Y") end end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Oct 20, 2010 at 11:21 PM, Todd Fisher <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > ruby-1.9.2-p0 => Sun 10 January 2010 > ruby-1.8.7-p302 => Fri 01 October 2010 > > One solution for Ruby 1.9.2 would be to redefine Date.parse as: > > class Date > def self.parse(input) > Date.strptime(input, "%m/%d/%Y") > end > end >You might also want to look at http://github.com/clemens/delocalize -- Erol M. Fornoles http://erolfornoles.posterous.com http://github.com/Erol http://twitter.com/erolfornoles http://ph.linkedin.com/in/erolfornoles -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.