📌  相关文章
📜  javascript 为时区的午夜创建日期对象 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:24.983000             🧑  作者: Mango

代码示例1
user:~$ node
> currentDate = new Date()
2021-10-07T11:27:33.520Z
> msTillMidnightSinceEpoch = currentDate.setUTCHours(0,0,0,0)
1633564800000
> ISTOffsetMS = (5*60 + 30)*60*1000 // +5:30
19800000
> requiredDate = new Date(msTillMidnightSinceEpoch + ISTOffsetMS)
2021-10-07T05:30:00.000Z
> requiredDate.toISOString()
'2021-10-07T05:30:00.000Z'
>