Skip to content

Instantly share code, notes, and snippets.

@OutsourcedGuru
Created November 22, 2017 16:37
Show Gist options
  • Save OutsourcedGuru/9c548f9f2737393f4791f922a198edb2 to your computer and use it in GitHub Desktop.
Save OutsourcedGuru/9c548f9f2737393f4791f922a198edb2 to your computer and use it in GitHub Desktop.
JavaScript Array Prototype
(function() {
Date.prototype.toLocalTime = function() {
// PDT -0700 = -7 * 60 = -420 minutes in the timezone offset from GMT to PDT
var nMillisecondsInMinute = 60000;
var nMillisecondsThis = this.getTime();
// Compensate for the GMT-stored time on production
if (isProduction)
nMillisecondsThis -= (420 * nMillisecondsInMinute);
return new Date(nMillisecondsThis);
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment