0

I have a Rails application that serves multiple tenant applications. These tenants can exist in different time zones, e.g. New York and LA. These tenant applications process payments and send data to my application. I am using PostgreSQL.

The data being sent is timestamped and includes the offset for the timezone in which the tenant exists. When my application receives and saves this data, ActiveRecord converts it to UTC without the offset.

Is it possible to configure ActiveRecord to preserve the timezone offset when the data is saved to the DB?

1 Answer 1

0

Save datetime in utc always. Whenever displaying the timestamp in views use

@post.created_at.in_time_zone(current_site.timezone)

current_site.timezone should return the timezone string corresponding to location.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.