javascript - Javascript 的 Date 对象依赖于用户的浏览器吗?

标签 javascript date browser time

我刚刚意识到,使用 Javascript 的 Date 对象获取日期可能会根据用户的浏览器/计算机返回不同的结果。是这种情况还是 Javascript 总是以某种方式返回实际时间,而不管用户计算机的设置如何?

最佳答案

是的,它根据用户系统日期返回日期:

The Date object enables the JavaScript developer to create a Date object initialized to a specific time and date, or to create a date object that reflects the current system time on the computer on which the browser is running. There are two important things to note when working with the JavaScript Date object. Firstly, when reading the date and time of the user's computer you are completely at the mercy of the user's ability to set and maintain the correct day and time on their computer. Secondly, whilst you can read the system date and time set on the user's computer, and change those settings within your Date object instance, you cannot change the computer's system date and time. No matter what methods you call or properties you change on your Date object, the user's system date and time remain unaltered.

http://www.techotopia.com/index.php/JavaScript_Date_Object

关于javascript - Javascript 的 Date 对象依赖于用户的浏览器吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17513680/

相关文章:

mysql - 如何格式化MySQL查询日期

r - 将 R 中的日期从破折号转换为斜线格式?

javascript - 鼠标悬停仅在我位于 Canvas 上而不是形状上时才激活

javascript - 如何让 while 循环将其结果存储在数组中,并重复 10 次?

jquery - 有谁知道jquery中计算时间流逝的插件吗?

javascript - IE6 不提交表单的最奇怪问题

javascript - 是否可以使用 Javascript 关闭 Android 浏览器?

javascript - iPhone Safari 浏览器,更改 # 哈希 URL,然后 Javascript 警报消息框停止工作

javascript - 将分层路径数组转换为 JSON

JavaScript 无法在应用程序上运行