MongoDB - Storing date without timezone

后端 未结 2 1479
北海茫月
北海茫月 2021-01-18 16:01

We have a simple application in which we have all user in same timezone & therefore we are not interested to store timezone information in mongo date object.

Re

2条回答
  •  日久生厌
    2021-01-18 17:03

    You could consider storing all the dates in UTC and presenting to the users in UTC, so you don't have the problem of silent conversion by either client JavaScript, server or MongoDB and therefore confusion. You can do it like this: new Date(Date.UTC(2000, 01, 28)) Here's MDN link on the subject.

提交回复
热议问题