//create a count down timer with own vanilla JS
function countDown(targetDate, targetMonth, targetYear) {
var targetCountDown = targetMonth+ " " + targetDate+ " " + targetYear+ " " + "23:59:59";
var targetCountDown = Date.parse(targetCountDown);
var currntTime = Date.parse(new Date());
var t = targetCountDown - currntTime;
var seconds = Math.floor( (t/1000) % 60 );
var minutes = Math.floor( (t/1000/60) % 60 );
var hours = Math.floor( (t/(1000*60*60)) % 24 );
var days = Math.floor( t/(1000*60*60*24) );
console.log(t);
if(t < 0) { return " 0:0:0 {Sorry Sir, Forgot your past, And go ahead!}" ; }
return {
'total': t,
'days': days,
'hours': hours,
'minutes': minutes,
'seconds': seconds
};
}
console.log(countDown(01,01,2020)); // Format will be DD/MM/YYYY
Output :- {total: 24222070000, days: 280, hours: 8, minutes: 21, seconds: 10}