I have a date in the database (firebase realtime database) that I'm fetching and I want to calculate the number of days between the database date and today's date.
I've seen the following answers on stackoverflow.
How do I get the number of days between two dates in JavaScript?
How to calculate the number of days between two dates? [duplicate]
How to get the number of days between two dates?
However, not a single answer helps me because I have different date formats. For instance this is the date format I'm storing in the database:
var date = (new Date()).toDateString().split(' ').slice(1).join(' ');
console.log(date);
and for today's date, it doesn't matter because I only want to get the number of days between these two dates.
I tried multiple ways to convert the date format of that in the database and then using the approach in the mentioned stackoverflow's answer to calculate the number of days but that didn't work.