In What Date Format Should I Store In The Firestore To Create A Dynamic Report Of Per Month?
I have a project to store the vaccination status of the users such as their 1st dose and 2nd dose. I would like to create a dynamic graph reporting for each of the vaccines. And I
Solution 1:
ISO strings are both human readable and sortable:
const date = newDate();
date.toISOString();
// => "2021-08-14T08:01:29.134Z"
If you don’t need readability, epoch time probably better for DB disk space:
const date = newDate();
date.getTime();
// => 1628928089134// ORDate.now();
// => 1628928089134
In both cases you can use the returned values to re-create the date object and get the month and year to use for filtering and analysis.
const recreatedDate = newDate("2021-08-14T08:01:29.134Z");
// alternatively:// const recreatedDate = new Date(1628928089134);// January is month number 0
recreatedDate.getMonth() + 1// => 8console.log(recreatedDate.getFullYear());
// => 2021
Post a Comment for "In What Date Format Should I Store In The Firestore To Create A Dynamic Report Of Per Month?"