Input time + timezone with Rails -


i want ask specific time includes timezone field. possible?

at moment i'm using retrieve time:

<%= f.time_select :meeting_time %> <%= f.time_zone_select :timezone %> 

and try change timezone:

meeting_time.in_time_zone(params[:meeting][:timezone]) 

but when user inputs time automatically set timezone on rails server(in case gmt). if user selects example gmt-1 decrease time 1 hour want increase times shown in gmt.

example:

the user inputs 18:00 gmt-1 , f.time_select put 18:00 utc. next, try convert gmt-1 in utc give me 17:00 gmt-1 instead of 19:00 gmt want.

note: not want show times in gmt don't think can save in other format without changing server timezone

i'm not sure if proper rails convention, it's workaround seems working fine me.

if change local time utc before saving database, should save correct utc time regardless of server time zone.

set time.zone current request

    time.zone = params[:meeting][:timezone] 

adjust utc

    meeting_time = time.zone.local_to_utc meeting_time 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -