I have two iso date and I want to calculate the day difference between two iso dates.I am unable to get the proper day difference.I want to calculate days.
date1=2020-08-14T09:10:49Z
date2=2019-08-06T09:10:49Z
daydifference=date1-date2;
I have two iso date and I want to calculate the day difference between two iso dates.I am unable to get the proper day difference.I want to calculate days.
date1=2020-08-14T09:10:49Z
date2=2019-08-06T09:10:49Z
daydifference=date1-date2;
You could achieve this by calculate the difference in millisecond between two date then divide by 1 day (also in millisecond)
Below snippet could help you
const date1 = '2020-08-14T09:10:49Z'
const date2 = '2019-08-06T09:10:49Z'
const DAY_UNIT_IN_MILLISECONDS = 24 * 3600 * 1000
const diffInMilliseconds = new Date(date1).getTime() - new Date(date2).getTime()
const diffInDays = diffInMilliseconds / DAY_UNIT_IN_MILLISECONDS
console.log(diffInDays, 'day(s)')