I know that Date object is using machine timezone (where the code is running). I have a specific use case that I need to clear the offset.
var d = new Date();
console.log(d.getTimezoneOffset())
This print the offset from the UTC. I'd like to force the offset to be zero and I did this
var getTimezoneOffset = Date.prototype.getTimezoneOffset;
Date.prototype.getTimezoneOffset = function removeTimezoneOffset() {
return 0;
};
and I reset after I did something
Date.prototype.getTimezoneOffset = getTimezoneOffset
This will fail in eslint complaining Date prototype is read only, properties should not be added
.
Is there any better way to remove the time offset?