如何获得客户的准确当地时间?
无论客户端系统的时区如何,获取客户端本地时间的最佳方法是什么?我正在创建一个应用程序,我首先需要获取客户访问地点的确切时间和日期.即使检测客户端系统的 IP 地址也有缺点,或者检测客户端系统的时区有时可能会有风险.那么,有什么方法可以真正可靠且不易出错,因为向客户显示错误的时间和日期是一件非常尴尬的事情.
What is the best method to get the clients local time irrespective of the time zone of clients system? I am creating an application and i need to first of all get the exact time and date of the place from where the client is accessing. Even detecting the ip address of client system has a drawback or detecting the time zone of client system may be risky at times. So, is there any way out which could be really reliable and not vulnerable to error because displaying wrong time and date to client is something very embarassing.
推荐答案
在 JavaScript 中?只需实例化一个新的日期对象
In JavaScript? Just instantiate a new Date object
var now = new Date();
这将使用客户端的本地时间创建一个新的 Date 对象.
That will create a new Date object with the client's local time.
相关文章