Created
August 4, 2020 06:01
-
-
Save andirkh/e40aa10b501d656d809dccf316caf365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function TimezoneDetect(){ | |
var dtDate = new Date('1/1/' + (new Date()).getUTCFullYear()); | |
var intOffset = 10000; | |
var intMonth; | |
var intHoursUtc; | |
var intHours; | |
var intDaysMultiplyBy; | |
// Go through each month to find the lowest offset to account for DST | |
for (intMonth=0;intMonth < 12;intMonth++){ | |
//go to the next month | |
dtDate.setUTCMonth(dtDate.getUTCMonth() + 1); | |
// To ignore daylight saving time look for the lowest offset. | |
// Since, during DST, the clock moves forward, it'll be a bigger number. | |
if (intOffset > (dtDate.getTimezoneOffset() * (-1))){ | |
intOffset = (dtDate.getTimezoneOffset() * (-1)); | |
} | |
} | |
return intOffset / 60; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment