Reputation: 6829
As I understand Firebase doesn't have DateTime data type. So as I think, it is best to use number of seconds since reference date which is double data type.
How can we then find objects that are created on specific date? Is there a way to write a query for it?
I am confused about DateTime type, but didn't find anything helpful in docs.
Upvotes: 2
Views: 2317
Reputation: 4623
The answer is less complex than you might think. Just convert your DateTime values to milliseconds-since-epoch. For example, Tue, 03 Jan 2017 17:35:17 GMT
becomes 1483464918000
. Every major language provides conversations to/from these values and native Date types.
Before you stumble into it, note one more detail: Firebase cannot sort in "descending" order when retrieving data. If you ever need to do this, store your value as a NEGATIVE NUMBER. (Or store a second myDateDescending: -1 * myDate
value in parallel.) Sorting on this negative-value field will produce a descending sort on that date value.
Upvotes: 5