如何获得客户的当地时间? [英] How to get the exact local time of client?

查看:123
本文介绍了如何获得客户的当地时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

客户系统的时区无论客户端本地时间如何,最好的方法是什么?我正在创建一个应用程序,我需要首先从客户端访问的地方获取确切的时间和日期。即使检测到客户端系统的ip地址也有缺点或检测到客户端系统的时区有时会有风险。所以,有什么办法可以真正可靠,不容易受到错误,因为向客户显示错误的时间和日期是非常尴尬的。

解决方案

在JavaScript中?只需实例化一个新的 日期对象

  var now = new Date(); 

这将创建一个新的Date对象与客户端的本地时间。


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.

解决方案

In JavaScript? Just instantiate a new Date object

var now = new Date();

That will create a new Date object with the client's local time.

这篇关于如何获得客户的当地时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆