Hi, My doubt is about how to make request to mysql using a different time than utf with this I try to say something like this User request for registers from 2012-02-13, his timezone is cst. Mysql works with utc so if a register was created after 6 p.m cst time it will be saved with the date like 2012-02-14 00:10:... so I''m wondering what I can do to show the user all the registers created in the date he asked depending in the timezone he is working. -- 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, Feb 15, 2012 at 7:47 PM, art tav <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > > My doubt is about how to make request to mysql using a different time > than utf with this I try to say something like this > > User request for registers from 2012-02-13, his timezone is cst. > > Mysql works with utc so if a register was created after 6 p.m cst time > it will be saved with the date like 2012-02-14 00:10:... so I''m > wondering what I can do to show the user all the registers created in > the date he asked depending in the timezone he is working. >You may consider using a real "Date" object to store a date ...> require ''date'' > Date.today.to_s #=> "2012-02-15"I made the mistake once to use Time (DateTime actually) to store a real "date" and it continued to create difficulties with different timezones etc. (not because of the language, but because of the "real life" issue that a contract starts at a certain _date_ and this is in reality a different time depending on the Time Zone). If you still can change it to a real date format in the database column, consider it seriously. HTH, Peter -- *** Available for a new project *** Peter Vandenabeele http://twitter.com/peter_v http://rails.vandenabeele.com http://coderwall.com/peter_v -- 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.
> You may consider using a real "Date" object to store a date ... > >> require ''date'' >> Date.today.to_s #=> "2012-02-15" > > I made the mistake once to use Time (DateTime actually) to store a real > "date" > and it continued to create difficulties with different timezones etc. > (not > because > of the language, but because of the "real life" issue that a contract > starts at a > certain _date_ and this is in reality a different time depending on the > Time Zone). > > If you still can change it to a real date format in the database column, > consider it > seriously.Well then you really suggest that I change the datetime format for a date format to deal with this issue? The time is used for knowing exactly when the transaction was made and we really need this information... but for purposes of searching and retrieving the information of the db may be I can create a new date field hmmm -- 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, Feb 15, 2012 at 9:22 PM, art tav <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > You may consider using a real "Date" object to store a date ... > > > >> require ''date'' > >> Date.today.to_s #=> "2012-02-15" > > > > I made the mistake once to use Time (DateTime actually) to store a real > > "date" > > and it continued to create difficulties with different timezones etc. > > (not > > because > > of the language, but because of the "real life" issue that a contract > > starts at a > > certain _date_ and this is in reality a different time depending on the > > Time Zone). > > > > If you still can change it to a real date format in the database column, > > consider it > > seriously. > > Well then you really suggest that I change the datetime format for a > date format to deal with this issue? The time is used for knowing > exactly when the transaction was made and we really need this > information... but for purposes of searching and retrieving the > information of the db may be I can create a new date field hmmm >* transaction time (needed for logging), will probably be a created_at for a new contract, new subscription, etc. (on a technical level) * contract_start_at would be more the "contractual/commercial/legal/ user facing" aspect of saying "you have started paying for the service from 15 Feb 2012, so it is valid until 14 Feb 2013". Of course the calculation of that Date still has to occur in the timezone of the user, so maybe my proposal does not really solve the root issue, or makes it even worse ? Hmmm, non-trivial ... Peter -- *** Available for a new project *** Peter Vandenabeele http://twitter.com/peter_v http://rails.vandenabeele.com http://coderwall.com/peter_v -- 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.
Well I think something like that would be the most elegant and simple solution because doing other things that I''ve been thinking about will require a lot of complex work and that could be bad solution in the end. Thanks for the idea -- 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.