Coder Social home page Coder Social logo

jquery.detect_timezone's Introduction

jQuery Detect TimeZone Plugin

This jQuery plugin leverages Jon Nylander's jstimezonedetect (based on work by Josh Fraser).

Why?

There are plenty of javascript examples out there showing how to work with the timezone offset. Unfortunately this approach has some disadvantages, especially in regards to day light savings.

Determining timezones using javascript is not trivial out of the box. Different browsers use different acronyms and conventions for representing names of timezones, it also differs depending on the user's operating system.

How to use

First, add the required scripts to your page (jquery, detect_timezone.js, and jquery.detect_timezone.js)

Then use one of the two timezone functions.

  1. set_timezone - sets the current timezone value by calling .val on the selector. This generally assumes the selector is an input (text or hidden).
  2. get_timezone - this method will return the current Olson timezone name.

Options:

  • debug - defaults to false. When true, it let you know that for some reason a timezone could not be found.
  • default - allows you to set a default value in the case no timezone could be found. Defaults to 'America/New_York'

Example:

<script>
	$(document).ready(function(){
			$('#tzvalue').set_timezone({
				'default' : 'America/Los_Angeles'
			});
	});
</script>

Note: There is an extremely minimal example in this repository.

Disclaimers

Blah, blah, blah....use it, tweak it, etc.

Always feel free to drop me a line at scottwater@gmail, but please use GitHub issues for any bugs/etc.

jquery.detect_timezone's People

Contributors

scottwater avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.