I have a date coming back in this format 2021-12-03T00:00:00.000Z
which I then convert to an ISO date string and then construct a new Date()
based on the split ISO string. The issue is that my date properly gets formatted with every month except December. Anytime I pass a December date, the logic always converts it to be January of the next year.
Code
//bill.date_paid at this point = '2021-12-03T00:00:00.000Z'
let isoDateString = new Date(bill.date_paid).toISOString().split('T')[0].split('-');
//isoDateString = ['2021', '12', '03'];
bill.date_paid = new Date(isoDateString[0], isoDateString[1], isoDateString[2]).getTime();
//date conversion above = 1641193200000 which is equal to a January date...
But why?