Javascript GMT/UTC timezone offset detection

|
Continuing from my previous date related PHP tip here is a very quick tip about how to detect the GMT/UTC timezone offset in Javascript. It really only takes two lines of code.


var today = new Date();
var offset = -(today.getTimezoneOffset()/60);


The above code will place the offset in hours in the offset variable in whatever context you made those two calls.

0 comments:

Post a Comment