Javascript日期/时间函数是否依赖于客户端机器?
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);
更多相关文章
- 获取指定日期的后(前)一(n)天(转)
- Python日期和时间函数
- Python 获得最近一个月的每天的日期
- python基础编程_12_日期格式的使用和转换
- Python -在文本文件中添加日期戳
- 请问用PL/SQL如何判断两个日期之间相差的天数?
- [置顶] SQL Server 日期相关
- 如何用sql语言只获得数据库当前日期,且格式为"yyyy-mm-dd"?
- 我想在每次更新或在SQL Server中插入行时获取当前日期时间