1
leeyuzhe 2021-12-02 16:08:55 +08:00
都转成时间戳或者都转成 utc 时间不就行了,没明白你什么意思
|
2
AngryPanda 2021-12-02 17:21:06 +08:00 via iPhone
难度在哪里🧐
|
3
BlackFri OP |
4
cluulzz 2021-12-02 22:29:00 +08:00 via iPhone
mongodb 聚合有个$function
|
5
unco020511 2021-12-03 09:51:30 +08:00
你想怎么存就怎么存啊,楼上不是说了,存时间戳或者 UTC 时间
|
6
gadfly3173 2021-12-03 11:21:05 +08:00
@BlackFri #3 从你这个链接里点进 Date 的说明可以看到:BSON Date is a 64-bit integer that represents the number of milliseconds since the Unix epoch (Jan 1, 1970). This results in a representable date range of about 290 million years into the past and future. 所以它存的就是时间戳吧。。。
|
7
leopod1995 2021-12-03 14:42:59 +08:00
Date.now 返回的也是时间戳, db 也是时间戳
|
8
BlackFri OP @leopod1995
db 是 ISO 时间戳 const diff = new Date(startTime).getTime() - new Date(new Date().toISOString()).getTime(); const diffMinutes = Math.abs(diff / 1000 / 60); if (diff > 30) { doSomething() } 已解决,感谢 |