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:
{
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()
.