Created
September 12, 2018 23:53
-
-
Save senthilmpro/7a48e87117e5a950cb7fd0239c198ea5 to your computer and use it in GitHub Desktop.
Internet Explorer Daylight savings - detect using Javascript
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 stdTimezoneOffset() { | |
var d = new Date(); | |
var jan = new Date(d.getFullYear(), 0, 1); | |
var jul = new Date(d.getFullYear(), 6, 1); | |
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); | |
} | |
/** | |
* Gets offset of current timezone and calculates if it has daylight timings enabled. | |
* @returns {boolean} | |
*/ | |
function dst() { | |
var d = new Date(); | |
return d.getTimezoneOffset() < stdTimezoneOffset(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment