Skip to content

Instantly share code, notes, and snippets.

@ianlevesque
ianlevesque / application.js
Created December 20, 2009 01:38
Automatically set the TimeZone in Rails >= 2.1
// detect time zone
Event.observe(window, 'load', function() {
var date = new Date();
date.setTime(date.getTime() + (1000*24*60*60*1000));
var expires = "; expires=" + date.toGMTString();
var offset = -(new Date().getTimezoneOffset() / 60);
document.cookie = "timezone=" + offset + expires + "; path=/";
});