Knowing the start time and the total number of seconds, we have calculated the countdown of hours, minutes and seconds. Use TS

1. Knowing the start time and the total number of seconds, we have calculated the countdown of hours, minutes and seconds. TS;
2. The output is 24 br 24 14 50, and what I want to achieve is a countdown to it;
countdown

      <p class="groupText_2"><b -sharphour>00</b>:<b -sharpminute>00</b>:<b -sharpsecond>00</b>

TS: //DOMJSDOM,HTML-sharphour/-sharpminute/-sharpsecond @ViewChild("hour") hour: ElementRef; @ViewChild("minute") minute: ElementRef; @ViewChild("second") second: ElementRef; var secondTime = 87890;// var minuteTime = 0;// var hourTime = 0;// if (secondTime > 60) {//60 //60 minuteTime = Math.floor(secondTime / 60); // secondTime = Math.floor(secondTime % 60); //60 if (minuteTime > 60) { //60 hourTime = Math.floor(minuteTime / 60); //60 minuteTime = Math.floor(minuteTime % 60); } } var resultTime = "" + Math.floor(secondTime); if (minuteTime > 0) { resultTime = "" + Math.floor(minuteTime) + ":" + resultTime; } if (hourTime > 0) { resultTime = "" + Math.floor(hourTime) + ":" + resultTime; } console.log(resultTime); // this.second.nativeElement.innerHTML = Math.floor(secondTime); // this.minute.nativeElement.innerHTML = Math.floor(minuteTime); // this.hour.nativeElement.innerHTML = Math.floor(hourTime);

write a countdown of seconds first, figure it out before you deal with this


this is the answer:

  this.secondTime = 87900;
  this.interval = setInterval(() => {
    if(this.secondTime > 60){
      this.secondTime--;
      var secondTime = 0; //
      var minuteTime = 0;// 
      var hourTime = 0;// 
      //60
      if (this.secondTime > 60) {
        //60
        minuteTime = Math.floor(this.secondTime / 60);
        //
        secondTime = Math.floor(this.secondTime % 60);
        //60
        if (minuteTime > 60) {
          //60
          hourTime = Math.floor(minuteTime / 60);
          //60
          minuteTime = Math.floor(minuteTime % 60);
        }
      }
      // 
      this.second.nativeElement.innerHTML = Math.floor(secondTime);
      //
      this.minute.nativeElement.innerHTML = Math.floor(minuteTime);
      //
      this.hour.nativeElement.innerHTML = Math.floor(hourTime);
    } else {
      this.alertPri.presentToast('');
      // 
      this.second.nativeElement.innerHTML = '00';
      //
      this.minute.nativeElement.innerHTML = '00';
      //
      this.hour.nativeElement.innerHTML = '00';
      clearInterval(this.interval);    
    }
  },1000)
  
  
  
  
  :
  this.countTime = () => {
  var date = new Date();
  var now = date.getTime();    
  var endDate = new Date("2018-12-6 11:00:00");
  var end = endDate.getTime();
  this.leftTime = end - now;                             
  var d, h, m, s, ms;
  if(this.leftTime >= 0) {
      // d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
      h = Math.floor(this.leftTime / 1000 / 60 / 60);
      m = Math.floor(this.leftTime / 1000 / 60 % 60);
      s = Math.floor(this.leftTime / 1000 % 60);
      ms = Math.floor(this.leftTime % 1000);
      if(ms < 100) {
          ms = "0" + ms;
      }
      if(s < 10) {
          s = "0" + s;
      }
      if(m < 10) {
          m = "0" + m;
      }
      if(h < 10) {
          h = "0" + h;
      }
      this.hour.nativeElement.innerHTML = h;
      this.minute.nativeElement.innerHTML = m;
      this.second.nativeElement.innerHTML = s;
  }
}

setInterval(this.countTime, 50);
if(this.leftTime < 0){
  //this.alertService.presentToast('');
  clearInterval(this.countTime);
  this.hour.nativeElement.innerHTML = '00';
  this.minute.nativeElement.innerHTML = '00';
  this.second.nativeElement.innerHTML = '00';
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be3e25-316a9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be3e25-316a9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?