Store date in MongoDB without considering the timezone

后端 未结 2 947
耶瑟儿~
耶瑟儿~ 2020-12-09 18:20

Which is the best way to store a date in MongoDB without considering the timezone?

I try to explain the problem with an example:

Giuseppe in Italy created an

2条回答
  •  萌比男神i
    2020-12-09 18:53

    Whole dates should not be placed in a Date object. Despite the name, Date represents a date and a time. If the value you're working with represents a whole date, rather than a specific time on that date, then you should store the value in another format.

    Options are:

    • A string in YYYY-MM-DD or YYYYMMDD format
    • An integer number of whole days since some reference point.

提交回复
热议问题