Skip to content

Instantly share code, notes, and snippets.

@senthilmpro
Created September 12, 2018 23:53
Show Gist options
  • Save senthilmpro/7a48e87117e5a950cb7fd0239c198ea5 to your computer and use it in GitHub Desktop.
Save senthilmpro/7a48e87117e5a950cb7fd0239c198ea5 to your computer and use it in GitHub Desktop.
Internet Explorer Daylight savings - detect using Javascript
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