How to do query with timezone settings in Mongodb

后端 未结 2 831
刺人心
刺人心 2020-12-19 02:53

I\'m trying to transfer my application database from Mysql to Mongodb, but I met a problem with datetime queries.

In Mysql, when there is a datetime or timestamp col

相关标签:
2条回答
  • 2020-12-19 03:39

    MongoDB stores all dates and times in UTC. This allows the timezone support and translation to be done application side instead of server side.

    The best way to store dates and times is via the Javascript Date object. This will allow you to convert dates to and from Unix timestamps, using getTime() and Date(milliseconds).

    It should be noted, that Javascript stores time in milliseconds since UNIX Epoch, whilst the standard UNIX timestamp is in seconds since Epoch.

    0 讨论(0)
  • 2020-12-19 03:40

    had a similar issue discussed here, https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/PodDGnWM09Q

    also, this website also might come in handy for future refrencing :) http://www.querymongo.com/

    0 讨论(0)
提交回复
热议问题