有没有办法在javascript中获取当前时区? [英] Is there any way to get current timezone in javascript?
本文介绍了有没有办法在javascript中获取当前时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
使用JavaScript获取客户端的时区
有没有无论如何在javascript中获取当前时区。所有我看到的是
Is there anyway to get current timezone in javascript. All i see is
Date.getTimeZoneOffset()
我面临的问题是,我有一个功能允许用户下载pdf,现在pdf必须包含一个'下载日期',应该是用户本地日期,必须在java中执行此操作。但它的所有令人困惑,我不知道我是否应该现场或只是时区将工作,每次当我尝试的结果是不同的!!!!
The problem I am facing is, I have a piece of functionality which allows the users to download pdf, now the pdf has to include a 'download date' in it which should be users local date, have to do this in java. But its all confusing, I dont know if i should locale or not or just the timezone will work, each time when i try something the results are different!!!!
推荐答案
代码:
var date = new Date();
document.write(date.toTimeString());
输出:
22:53:21 GMT+0530 (India Standard Time)
^offset ^timezone
这篇关于有没有办法在javascript中获取当前时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文