I want to calculate date difference in days, hours, minutes, seconds, milliseconds, nanoseconds. How can I do it?
I think this should do it.
let today = new Date(); let form_date=new Date('2019-10-23') let difference=form_date>today ? form_date-today : today-form_date let diff_days=Math.floor(difference/(1000*3600*24))