【发布时间】:2023-03-18 22:07:01
【问题描述】:
如何将 UK endDate 转换为 UTC,以便与节点上的 UTC 当前时间 (nowTime) 进行比较?还是以其他方式更好?将当前UTC时间转换为伦敦时区,然后与英国endDate进行比较
例如:
const nowTime = new Date('Thu May 10 2020 15:55'); //mock now time in UTC
const date = { //this is london date/time
EndDate: "2020-05-10",
EndTime: "15:57",
}
const combineDateTime = date.EndDate + " " + date.EndTime;
const endDate = new Date(combineDateTime).getTime();
if (nowTime >= endDate) {
console.log('expired');
} else {
console.log('not expired')
}
【问题讨论】:
-
你能详细说明一下你如何比较只是日期吗?只有时间?你想要的输出是什么?
-
比较从 nowTime 到 Endate 的日期和时间。
nowTime > endDate
标签: javascript node.js momentjs