使用EPOC值JavaScript计算客户端服务器UTC偏移量
我们正在尝试通过使用从后端API发送的EPOC值来计算客户端服务器时间的偏移,而在此操作中,我遇到了本地浏览器/客户端端的问题。
当我从后端API IE ESERVEREPVALUE获得EPOC时?
const serverdate = new Date(1653107370620)
serverdate = SAT 5月21日2022 09:59:30 GMT+0530(语言环境浏览器日期和时间)
如何使用EPOC获得服务器UTC时间来计算客户端的偏移?
We are trying to calculate the client-server time offset by using EPOC value sent from backend API, when doing that I am running into an issue in local browser/client side.
when i get EPOC from backend API I.e. serverEpocValue = 1653107370620 and trying to compare it with the local epoc value the difference is not 6 hours as I expected, it's around few milliseconds difference, why is epoc value close to local time instead of the server time?
const serverdate = new Date(1653107370620)
serverDate =
Sat May 21 2022 09:59:30 GMT+0530 (locale browser date and time)
How do we get the server UTC time using epoc to calculate the offset in the client side?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设施的时间
date.now()
将始终从1970年1月1日UTC开始,并且不考虑时区。如果需要获得时区偏移,则应使用date.getTimeZoneOffset
https://developer.mozilla.org/en-us/docs/docs/web/javascript/javascript/global_object/global_objects/date/getTime/getTimeZoneOfkseft
global_objects/date/getTimeZoneOffset“ rel =“ nofollow noreferrer 分钟。
The time through facilities
Date.now()
will always be in milliseconds from Jan 1 1970 UTC and does not consider timezones. If you need to get the timezone offset you should use something likeDate.getTimezoneOffset
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
which will return the offset in minutes.