Skip to content

Instantly share code, notes, and snippets.

@treevis
Created March 16, 2015 02:56
Show Gist options
  • Save treevis/90a5432b33ba8acc11fe to your computer and use it in GitHub Desktop.
Save treevis/90a5432b33ba8acc11fe to your computer and use it in GitHub Desktop.
Get User's Timezone
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Set timezone</title>
</head>
<body>
<!-- http://pellepim.bitbucket.org/jstz/ -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js"></script>
<script>
var tz = jstz.determine(),
tz_name = 'UTC';
if(typeof(tz) !== 'undefined') {
tz_name = tz.name();
}
document.cookie = 'timezone=' + tz_name + ';path=/';
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment