JSFiddle - React, Tailwind, and code Playground

JavaScript

var DayDiff = function (start) {
    var now = new Date().getTime();
    start = new Date(start).getTime();
    
    return Math.floor((now - start)/ 86400000);
};

document.write("Future Date '2012-02-05': " + DayDiff('2012-02-05'));
document.write("<br/>");
document.write("Past Date '2012-02-01': " + DayDiff('2012-02-01'));