const seconds=1000, minute=60*seconds,hours= 60*minute,day= 24*hours;
const days= document.querySelector(".days");
const hrs= document.querySelector(".hrs");
const min= document.querySelector(".min");
const sec= document.querySelector(".sec");
//main target
//function
const timerfunction =()=>{
let dd = prompt("Enter Date").padStart(2,"0");
let mm = prompt("Enter Month").padStart(2,"0");
let yyyy =prompt ("Enter Year") ;
console.log(`${dd}/${mm}/${yyyy}`);
const target = `${dd}/${mm}/${yyyy}`;
console.log(target);
let targetdate = new Date(Date.parse(target)).getTime();
console.log(targetdate);
setInterval(()=>{
//get current time
const currentdate = new Date();
var currentdates = currentdate.getTime();
const difference =targetdate-currentdates;
const differencedays = Math.floor((difference)/day );
const differencehours = Math.floor(((difference)%day)/hours);
const differencemins = Math.floor(((difference)%hours)/minute);
const differenceseconds = Math.floor(((difference)%minute)/seconds);
days.innerText =differencedays;
hrs.innerText =differencehours ;
min.innerText =differencemins ;
sec.innerText =differenceseconds;
console.log(`${differencedays}:${differencehours}:${differencemins}:${differenceseconds}`);
}, 1000);
}
timerfunction();
what is the problem with targetdate ? during the counter timer project where i am printing the remaining time on the screen id=f the currentdate stores the current date and targetdate stores the future targeted date .and timerfunction is the function which tells the remaining time. targetdate is returning NaN , why?