js countdown Synchronize question when my two users, Synchronize, open this page, their countdown time will be a few seconds apart.
PS: how should I write this countdown
PS:? is there something wrong with my writing?
let expires_at = new Date(this.order.expires_at.replace(/-/g, "/")); //
let myDate = new Date()//
let ms = expires_at-myDate //
let mm = parseInt(ms/60000)//
let mss = ms%60 //
this.minutes = mm
this.seconds = mss
a()
function a(){
setInterval(()=>{
if (this.seconds == 0 && this.minutes != 0) {
this.seconds = 59;
this.minutes -= 1;
}else if(this.minutes == 0 && this.seconds == 0){
this.seconds = 0;
clearInterval();
}else{
this.seconds -= 1
}
},1000);
}