I was wondering if Javascript date/time functions will always return correct, universal dates/times or whether, Javascript being a client-side language, they are dependent on what the client machine has its date set to.

我想知道Javascript日期/时间函数是否总是返回正确的、通用的日期/时间,或者Javascript是一种客户端语言,它们是否依赖于客户机机器设置的日期。

If it is dependent on the client machine, what is the best way to get the correct universal time?

如果它依赖于客户端机器,那么获得正确的通用时间的最佳方法是什么?

4 个解决方案

#1


3

As thomasrutter has said javascript date functions are reliant on the client's machine. However if you want to get an authoritative date you could make and ajax request to your server that just returns the date string. You can then convert the date string into a date object with the following

正如thomasrutter所说,javascript日期函数依赖于客户机的机器。但是,如果您想获得一个权威的日期,您可以向您的服务器发出ajax请求,该请求只返回日期字符串。然后,您可以使用以下命令将日期字符串转换为日期对象

var ds = ... // Some ajax call
var d = new Date(ds);

更多相关文章

  1. 获取指定日期的后(前)一(n)天(转)
  2. Python日期和时间函数
  3. Python 获得最近一个月的每天的日期
  4. python基础编程_12_日期格式的使用和转换
  5. Python -在文本文件中添加日期戳
  6. 请问用PL/SQL如何判断两个日期之间相差的天数?
  7. [置顶] SQL Server 日期相关
  8. 如何用sql语言只获得数据库当前日期,且格式为"yyyy-mm-dd"?
  9. 我想在每次更新或在SQL Server中插入行时获取当前日期时间

随机推荐

  1. Android学习笔记06-线性布局LinearLayout
  2. android画图---Layer
  3. ListView去掉分割线的几种方法
  4. 流媒体开发重要参考纪要
  5. Android 获取汉字拼音
  6. Android VideoView设置静音,Android 设置
  7. Android获取所有安装APP信息
  8. RK3326 Android 8.1 为自己的APK的服务默
  9. 调用android 中的拨号功能、调用某个联系
  10. Android属性之android:priority