Skip to content

Automatically detect the user's timezone and apply it in your Rails controllers

Notifications You must be signed in to change notification settings

magoosh/browser-timezone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Browser Timezone (for Rails)

This gem automatically detects the user's timezone offset from their browser by setting a cookie, then applies it in the controller by setting Time.zone to the appropriate timezone.

Installation

Add the gem to your Gemfile:

gem 'browser-timezone', :git => "git://github.com/magoosh/browser-timezone.git"

Usage

In your controller:

class ApplicationController < ActionController::Base
  set_timezone_from_browser
end

That's it.

Thanks to @technoweenie's article for the inspiration.

About

Automatically detect the user's timezone and apply it in your Rails controllers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages