Skip to content

Instantly share code, notes, and snippets.

@Savantos
Forked from jgable/currentTimezone.js
Created April 2, 2013 22:08
Show Gist options
  • Save Savantos/5296654 to your computer and use it in GitHub Desktop.
Save Savantos/5296654 to your computer and use it in GitHub Desktop.
// Some basic javascript Date examples
// NOTE: Javascript dates have 0 indexed months, because they are awesome
// January 1, 2012 (Chicago, IL)
var firstOfYear = new Date(2012, 0, 1),
// 6 Hour offset (before DST change)
hoursOffset = firstOfYear.getTimezoneOffset() / 60;
// April 1, 2012 (Chicago, IL)
var afterDST = new Date(2012, 3, 1),
// 5 Hour offset (after DST change)
hoursOffset = afterDST.getTimezoneOffset() / 60;
// November 16, 2012 (Chicago, IL)
var postDate = new Date(2012, 10, 16),
// 6 Hour offset (after DST change back)
hoursOffset = postDate.getTimezoneOffset() / 60;
# US central time, represented by Chicago
# Alabama, Arkansas, Florida panhandle (Bay, Calhoun, Escambia,
# Gulf, Holmes, Jackson, Okaloosa, Santa Rosa, Walton, and
# Washington counties), Illinois, western Indiana
# (Gibson, Jasper, Lake, LaPorte, Newton, Porter, Posey, Spencer,
# Vanderburgh, and Warrick counties), Iowa, most of Kansas, western
# Kentucky, Louisiana, Minnesota, Mississippi, Missouri, eastern
# Nebraska, eastern North Dakota, Oklahoma, eastern South Dakota,
# western Tennessee, most of Texas, Wisconsin
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER
Rule Chicago 1920 only - Jun 13 2:00 1:00 D
Rule Chicago 1920 1921 - Oct lastSun 2:00 0 S
Rule Chicago 1921 only - Mar lastSun 2:00 1:00 D
Rule Chicago 1922 1966 - Apr lastSun 2:00 1:00 D
Rule Chicago 1922 1954 - Sep lastSun 2:00 0 S
Rule Chicago 1955 1966 - Oct lastSun 2:00 0 S
var someUTCDate = new Date(new Date().getTime()),
chicagoWallTime = WallTime.UTCToWallTime(someUTCDate, "America/Chicago"),
backToUTCTIme = WallTime.WallTimeToUTC("America/Chicago", chicagoWallTime);
<script src="/path/to/walltime-data.js"></script>
<script src="/path/to/walltime.js"></script>
<script type="text/javascript">
var someUTCDate = new Date(new Date().getTime()),
chicagoWallTime = WallTime.UTCToWallTime(someUTCDate, "America/Chicago");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment