Does Javascript use the local computer time?

隐身守侯 提交于 2021-01-27 05:31:26

问题


This may be a dumb question, I'm 99% sure it does, but I need to be sure... does JS use the local computer's time?


回答1:


Yes it does use the computer's local time. To test, change your computer time and it will reflect in new Date




回答2:


It'll use the time on whatever computer is running the code.

In most cases, that's in a web browser on a client computer, so it'll use whatever time the web browser sees. This is most likely the computer's local time (unless the browser is doing something weird, which most don't and I've never seen).

Note that if you're using something like node.js and running server-side Javascript then it'll use the local time for that computer instead :)




回答3:


JS is client-side script language and as all client-side languages it can't get server time. The only way to get server time is sending request to server via AJAX (or any ActivX based tecnology).



来源:https://stackoverflow.com/questions/4234536/does-javascript-use-the-local-computer-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!