I have records in database which has created_at field in UTC.
In need to show it in active_admin table as a time in user timezone.
For example:
in DB created at 2017-12-25 15:52:58
on page: 2017-12-25 15 17:52:58
I tried to use this code in activeadmin
paginated_collection(user_actions.page(params[:page]).per(15), download_links: false) do
table_for(collection, sortable: false) do |action|
column ("Timestamp"){|action| action.created_at.in_time_zone('EET').strftime("%Y-%m-%d %H:%M:%S")}
end
end
and it works fine. But I need to get user timezone constant programmatically to pass it into
in_time_zone(timezone_variable)
or
in_time_zone(get_current_timezone_method)
I tried to get it like this
Time.zone.now.name
but it doesn't work and I think it because this code try to get server timezone but not a client. Is there any way to get client timezone on client side and display created_at in active_admin which include timezone correction? Also (if previous way is impossible) I thought about another way - to store users timezone in DB when user signed in. And get it from DB to pass into
in_time_zone(action.user.timezone)
. Is there any way to get users timezone constant in controller action on server side to store it in DB?