Hello, I am running into a little issue. There is a considerable time difference between the time that the console is giving me and the time I am seeing in the created_at and updated_at column in the DB. The difference is about 5 hours. I don''t think the problem is in the DB, but I could be wrong. Am I missing something obvious? Any clues? -- 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.
check timezone settings in your environment configs -- 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.
Hello, Sorry if this is a double post. I think I did something wrong with the original one. I am running into a little problem with the fields mentioned above. The difference between what Rails is saving in the DB and what I can see in the console is of about 5 hours. Am I missing something obvious? Anybody has a clue about what might be going on? Thank you. -- 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 13 December 2010 21:54, pepe <Pepe-gUAqH5+0sKL6V6G2DxALlg@public.gmane.org> wrote:> Hello, > > I am running into a little issue. There is a considerable time > difference between the time that the console is giving me and the time > I am seeing in the created_at and updated_at column in the DB. The > difference is about 5 hours. > > I don''t think the problem is in the DB, but I could be wrong.The value in the db should be UTC, so may be correct, dependent on where you are. Colin -- 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.
Thanks, the time_zone value in environment.rb is the reason this is happening. On Dec 13, 5:05 pm, Anton Anykeyev <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> check timezone settings in your environment configs > > -- > 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.
> The value in the db should be UTC, so may be correct, dependent on > where you are.Thanks Colin, I am in the US, EST. UTC is 5 hours ahead of me (rake time:zones:all). For a multiple time zone application I understand that having UTC would be "the" option. Is there a reason I am not aware of why I should still use UTC for a single time zone application? -- 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 14 December 2010 01:26, pepe <Pepe-gUAqH5+0sKL6V6G2DxALlg@public.gmane.org> wrote:>> The value in the db should be UTC, so may be correct, dependent on >> where you are. > > Thanks Colin, > > I am in the US, EST. UTC is 5 hours ahead of me (rake time:zones:all). > For a multiple time zone application I understand that having UTC > would be "the" option. Is there a reason I am not aware of why I > should still use UTC for a single time zone application?So there is never any ambiguity about timestamps in the database. For example, suppose you move to a server in another timezone, it can get very messy if you have timestamps in EST or whatever happens to be your local timezone today. By keeping all timestamps in the db in UTC you will always know what they mean. Normally Rails will do the conversion to local time for you so the fact that it is UTC in the db is not something you need normally worry about. Colin -- 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.
> So there is never any ambiguity about timestamps in the database. For > example, suppose you move to a server in another timezone, it can get > very messy if you have timestamps in EST or whatever happens to be > your local timezone today. By keeping all timestamps in the db in UTC > you will always know what they mean.I understand the benefits of UTC, however...> Normally Rails will do the > conversion to local time for you so the fact that it is UTC in the db > is not something you need normally worry about.This is the reason why I noticed. I have to display on screen the date and time from updated_at and I saw that while my local time was around 4:00 PM the screen was displaying around 9:00 PM. In other words, there is no ''conversion'' going on. I don''t know if it makes a difference but when I display the values I am not displaying the full value of updated_at, I have to break it down in 2 values, date and time, and I am using strftime to do the job. Should I be using something different and/or converting the values to local time first somehow? -- 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.
On 14 December 2010 13:46, pepe <Pepe-gUAqH5+0sKL6V6G2DxALlg@public.gmane.org> wrote:> >> So there is never any ambiguity about timestamps in the database. For >> example, suppose you move to a server in another timezone, it can get >> very messy if you have timestamps in EST or whatever happens to be >> your local timezone today. By keeping all timestamps in the db in UTC >> you will always know what they mean. > > I understand the benefits of UTC, however... > >> Normally Rails will do the >> conversion to local time for you so the fact that it is UTC in the db >> is not something you need normally worry about. > > This is the reason why I noticed. I have to display on screen the date > and time from updated_at and I saw that while my local time was around > 4:00 PM the screen was displaying around 9:00 PM. In other words, > there is no ''conversion'' going on. I don''t know if it makes a > difference but when I display the values I am not displaying the full > value of updated_at, I have to break it down in 2 values, date and > time, and I am using strftime to do the job. Should I be using > something different and/or converting the values to local time first > somehow?Use created_at.localtime.strftime( .... ) Colin -- 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.
> Use created_at.localtime.strftime( .... )Couldn''t have been any easier. Thanks Colin. -- 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.