无论客户端系统的时区如何,获取客户端本地时间的最佳方法是什么?我正在创建一个应用程序,我首先需要获取客户访问地点的确切时间和日期.即使检测客户端系统的 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.
这篇关于如何获得客户的准确当地时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 Angular 2/Typescript 中使用 IScrollUse IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
Anime.js 在 Ionic 3 项目中不起作用anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 项目中不起作用)
Ionic 3 - 使用异步数据更新 ObservableIonic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用异步数据更新 Observable)
Angular 2:在本地 .json 文件中找不到文件Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
在 Ionic 2 中,如何创建使用 Ionic 组件的自定义指In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何创建使用 Ionic 组件的自定义指令?)
将 ViewChild 用于动态元素 - Angular 2 &离子2Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(将 ViewChild 用于动态元素 - Angular 2 amp;离子2)