Skip to content

Instantly share code, notes, and snippets.

@glasner
Created February 24, 2010 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glasner/312990 to your computer and use it in GitHub Desktop.
Save glasner/312990 to your computer and use it in GitHub Desktop.
// run on <select>
$.fn.timeZone = function() {
return this.extend({
selectUserTimezone: function(){
var timeZone = (new Date().getTimezoneOffset() / 60) + ':00'; // => '5:00'
this.find("option:contains(" + timeZone + "):first").attr('selected', 'selected')
}
})
};
// $('select.time_zone').timeZone().selectUserTimeZone()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment