To add: Just to make things clear if this is you. If you are thinking
that Rails will store the data inside of the db as your timezone it
won't. Rails stores all times as UTC so they can be converted easily
no matter the system, the timezones only apply to the final object
created. You can also try just setting the city name ("New York") and
see if that works though Eastern should work.
1.9.3-p286 :002 > Time.zone = ‘Eastern Time (US & Canada)’
=> “Eastern Time (US & Canada)”
1.9.3-p286 :003 > Time.zone.now
=> Thu, 07 Feb 2013 01:35:00 EST -05:00
Above is working well.
Case 1:
But i need to store each records in database with that time stamp. i.e created_at and updated_at need to be EST, not in UTC.
Case 2:
Also I need store all records created_at and updated_at with client country time, if one client in NewYork, need to store their time and other person in India, their time need to store.
1.9.3-p286 :001 > Time.zone.now
=> Thu, 07 Feb 2013 06:34:49 UTC +00:00
1.9.3-p286 :002 > Time.zone = 'Eastern Time (US & Canada)'
=> "Eastern Time (US & Canada)"
1.9.3-p286 :003 > Time.zone.now
=> Thu, 07 Feb 2013 01:35:00 EST -05:00
Above is working well.
Case 1:
But i need to store each records in database with that time stamp. i.e
created_at and updated_at need to be EST, not in UTC.
Why? Don't do it, always store it in UTC.
Case 2:
Also I need store all records created_at and updated_at with client
country time, if one client in NewYork, need to store their time and other
person in India, their time need to store.
Please don't top post, it makes it difficult to follow the thread.
Insert your reply at appropriate points in previous message. Thanks.
Because my application will use in several country so I need to know what
time they are creating records.
You will know the time (in UTC). If you store updated_at, for
example, in the local timezone and you have one record with an
update_at of 12:00 and another 13:00 (for a different user) then you
would not know which came first. If they are all in UTC then you know
the exact time it actually happened.