//expected format date in = dd/mm/yyyy, return date rounded number in month function dateDiffInMonth(startDate, endDate){ // Convert to date type var aryTarikhMula = startDate.split('/'); var tarikhMulaMDY = aryTarikhMula[1] + '/' + aryTarikhMula[0] + '/' + aryTarikhMula[2]; var dtTarikhMula = new Date(tarikhMulaMDY); var aryTarikhTamat = endDate.split('/'); var tarikhAkhirMDY = aryTarikhTamat[1] + '/' + aryTarikhTamat[0] + '/' + aryTarikhTamat[2]; var dtTarikhAkhir = new Date(tarikhAkhirMDY); var diff = dtTarikhAkhir - dtTarikhMula; var diffInMonth = (diff/1000 / 60 / 60 / 24) / 30; diffInMonth = diffInMonth.toFixed(0); return diffInMonth; }
Friday, December 23, 2016
Date Different in Month
Labels:
Javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment