I'm running into an issue where I am trying to find the maximum day in an array of dates, but for some reason it keeps returning either Invalid Date
or null
. I'm not sure what's going wrong. Do you think I should convert the values to a different format? Any assistance would be greatly appreciated.
const dates=[
'2022-10-13T00:00:00.000',
'2023-10-14T00:00:00.000',
'2024-10-15T00:00:00.000',
'2020-10-16T00:00:00.000',
'2015-10-17T00:00:00.000',
'2028-10-18T00:00:00.000',
'2010-10-19T00:00:00.000',
]
//const maxDate=new Date(Math.max.apply(null,dates));
const maxDate=new Date(
Math.max(
...dates
),
)
console.log('maxDate', maxDate)