如何根据JS中的当前DateTime获取UTC DateTime?
我尝试根据用户的当前日期时间获取DateTime。例如,如果我想在UTC中获得当前日期的开始,
const start = new Date()
start.setUTCHours(0,0,0,0)
如果我想在UTC中结束当前日期,
const end = new Date()
end.setUTCHours(23,59,59,999)
但是当我委托时
Sun Jun 05 2022 17:00:00 GMT-0700 (Pacific Daylight Time)
。时间)”? )
那如果我想在5天前获得当前数据呢?该怎么办?就像现在本地日期时间是PST下午2:35一样,我该如何在5天前2:35 PM获得,但在UTC中(应该是7:35 pm,对吗?)谢谢!
I try to get datetime based on user's current datetime. For example, if I want to get the start of the current date in utc,
const start = new Date()
start.setUTCHours(0,0,0,0)
if I want to get the end of the current date in utc,
const end = new Date()
end.setUTCHours(23,59,59,999)
but when I console.log start, it's
Sun Jun 05 2022 17:00:00 GMT-0700 (Pacific Daylight Time)
May I know why there's this "(Pacific Daylight Time)"? )
So what if I want to get 5 days ago of current datetimt? Like if now local datetime is 2:35pm pst, how do I get 5 days ago 2:35 pm but in utc (which should be 7:35pm right?) Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论