All you need to do is replace the string variable dtStr and Javascript Now method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | var dtStr = "24/11/2018"; var r=dtStr.split('/'); var dtObj = new Date(r[2],r[1]-1,r[0]); var today = new Date(); var day = today.getDate(); var month = today.getMonth()+1; var year = today.getFullYear(); if(day<10) { day='0'+dd; } if(month<10) { month='0'+month; } var today = day+'/'+month+'/'+year; var trans=today.split('/'); var obj = new Date(trans[2],trans[1]-1,trans[0]); if(obj> dtObj) { document.write("Today date is greater than past date" + dtObj.toLocaleDateString()); } else { document.write("Today date is lesser than past date" +dtObj.toLocaleDateString()); } |