JSFiddle - React, Tailwind, and code Playground

by Sajeetharan Sinnathurai

JavaScript

var date1 = new Date("12/30/2012");
var date2 = new Date("3/31/2013");
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); 
var diffmonths = Math.ceil(timeDiff / (1000 * 3600 * 24 *12)); 
alert("DAYS"+ " " +diffDays);
alert("MONTHS"+ " " + diffmonths);