Storing dates with angular and firebase

前端 未结 1 1020
攒了一身酷
攒了一身酷 2021-01-27 07:10

I\'m creating an angular + firebase food journal and I\'m having a logic freeze concerning dates and how best to store them. My data structure looks like:

{
             


        
相关标签:
1条回答
  • 2021-01-27 07:44

    Storing dates in yyyyMMdd format is fairly common. It has the advantage that the resulting values are numerically comparable, i.e. the number for tomorrow is bigger than the one for today.

    An even more common alternative is to store in "(milli)seconds since the epoch". Not only is that numerically comparable, but it is also what Date.now() returns and can be passed into new Date().

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