November 4, 2016

How to get timezone of client machine with JavaScript?

function formatedZone() { var now = new Date(), tzo = -now.getTimezoneOffset(), dif = tzo >= 0 ? ‘+’ : ‘-‘, pad = function(num) { var norm = Math.abs(Math.floor(num)); return (norm < 10 ? ‘0’ : ”) + norm; }; return dif+pad(tzo / 60)+ ‘:’ +pad(tzo % 60); }