i want to store timezone of client (visitor)
which going to use my web portal.
would you please show me way to find out timezone for client machine using JAVAScript
code...
I need the GMT offset hours like `(GMT +5:30)`.
This could be a better approach to find client local time/offset
function pad(number, length){
var str = "" + number;
while (str.length < length) {
str = '0'+str;
}
return str;
}
var offset = new Date().getTimezoneOffset();
offset = ((offset<0? '+':'-')+ pad(parseInt(Math.abs(offset/60)), 2)+":"+pad(Math.abs(offset%60), 2));
alert(offset);
The output would be like = +05:30
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With