i am using angular12, here calculation of days based on 2 dates works fine with chrome, but the same thing fails in firefox.
TS: Using Moment, gives invalid date error under firefox:
getDaysCount(firstDate: any, secondDate: any) {
let first = moment(firstDate, 'MM-DD-YYYY');
let second = moment(secondDate, 'MM-DD-YYYY');
return second.diff(first, 'days');
}
console.log(this.getDaysCount('11-12-2022', '11-14-2022));
var Difference_In_Days = Math.ceil(Math.abs(secondDate - firstDate) / (1000 * 60 * 60 * 24));
this gives NAN in firefox but gives 2 in chrome.
CodePudding user response:
Chrome console: