I want to calculate DaysSinceLastLogin, and want to use the below functionality(Found on google):
const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds
const firstDate = new Date(2008, 1, 12);
const secondDate = new Date(2008, 1, 22);
const diffDays = Math.round(Math.abs((firstDate - secondDate) / oneDay));
So with my scenario, My firstdate format is in string: "2020-03-06 18:20:36:187"
and the secondDate would be today's date so basically I need the firstDate and secondDate to be passed in the above function but format is different, how can I convert firstdate and today's date in the required format?