JSFiddle - React, Tailwind, and code Playground
HTML
<input type='text' id='expiryDT' style='width:200px;margin-left:15px;' value='24-06-2013 23:20:20' readonly='readonly'>
JavaScript
var expTime = String(document.getElementById("expiryDT").value);
var year = expTime.match(/\d\d\d\d/)[0];
var month = expTime.match(/-(\d\d)-/)[1] - 1;
var day = expTime.match(/^\d\d/)[0];
expTime = new Date(year, month, day);
var unixBts=new Date(expTime).getTime()/1000;
//alert(unixBts);
const _MS_PER_DAY = 1000 * 60 * 60 * 24;
// a and b are javascript Date objects
function dateDiffInDays(a, b) {
// Discard the time and time-zone information.
const utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
const utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
return Math.floor((utc2 - utc1) / _MS_PER_DAY);
}
// test it
const a = new Date("10.09.2018"),
b = new Date(),
difference = dateDiffInDays(a, b);
alert(difference);