I want to find the difference between two dates,
I have an array which contains objects that include a startDate and endDate.
I have been trying this.
testData.forEach((item) => {
const { endDate, startDate } =
item;
if (workflow_instances_timestamp && workflow_instances_modified_at) {
let startDate_ = new Date(startDate );
let endDate_ = new Date(endDate);
const seconds =
Math.abs(endDate_.getTime() - startDate_.getTime()) / 1000;
console.log(startDate, "startDate");
console.log(endDate, "endDate");
console.log(seconds % 60, "seconds");
}
});
the data contains this array
const items = [{endDate: "Fri Jun 30 2023 13:32:05 GMT+0200 (Central European Summer Time)", startDate: "Fri Jun 30 2023 15:31:51 GMT+0200 (Central European Summer Time)"}]
with this code I have provided the seconds are showing is 46 seconds.
Which its not correct.
Thanks a lot.