我想存储timezone of client (visitor)哪些将使用我的门户网站.你能告诉我找出timezone for client machine using JAVAScript代码的方法吗?
I need the GMT offset hours like `(GMT +5:30)`.
Run Code Online (Sandbox Code Playgroud)
这可能是查找客户端本地时间/偏移量的更好方法
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);
Run Code Online (Sandbox Code Playgroud)
输出将类似于= +05:30
| 归档时间: |
|
| 查看次数: |
8076 次 |
| 最近记录: |