I\'m dealing with dates and times in Rails and Postgres and running into this issue:
The database is in UTC.
The user sets a time-zone of choice in the Rails
If you want to deal in UTC by default:
In config/application.rb
, add:
config.time_zone = 'UTC'
Then, if you store the current user timezone name is current_user.timezone
you can say.
post.created_at.in_time_zone(current_user.timezone)
current_user.timezone
should be a valid timezone name, otherwise you will get ArgumentError: Invalid Timezone
, see full list.