Skip to content

Instantly share code, notes, and snippets.

@joelvh
Created October 10, 2013 18:57
Show Gist options
  • Save joelvh/6923580 to your computer and use it in GitHub Desktop.
Save joelvh/6923580 to your computer and use it in GitHub Desktop.
Parse time in time zone in Rails
# parse date/time in detected time zone
time_zone_name = params[:time_zone]
time_zone = ActiveSupport::TimeZone.new(time_zone_name || Time.zone.name)
time_string = "#{params[:date]} #{params[:time]}"
time_in_time_zone = time_zone.parse time_string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment