peter peter - 1 month ago 11
Javascript Question

setTimezoneOffset globally for whole script

Hello I am using

getTimezoneOffset
an it returns e.g.
-60


How could I set global timezone offset for javascript? I tried
setTimezoneOffset('-120');
but it is not working. I would like to set it globally at start of the script so later I will be able simply call
var d = new Date(); var n = d.getTimezoneOffset();
and it returns my value. Please just solution exactly for this case. Thank you!

Answer
Date.prototype.getTimezoneOffset = function () {return -120;};