The final result is this pulsing countdown:

// Convert the date to milliseconds
  getCountDown() {
  Replace (/-/g, '/'); // Convert the start time to milliseconds // Note that the format is YYYY-MM-DD hh:mm:ss.
    const startTime: any = new Date(
      this.houseData.judicialSaleHouse.auctionTime.replace(/-/g.'/')
    ).getTime();
    // Get the current time converted to milliseconds
    const nowTime: any = new Date().getTime();
    // Calculate the millisecond difference
    const timeLag = startTime - nowTime;
    if (timeLag > 0) {
    // Split the number of milliseconds
      this.day = parseInt((timeLag / (1000 * 60 * 60 * 24)).toString());
      // Count the hours
      this.hour = parseInt(
        ((timeLag % (1000 * 60 * 60 * 24))/(1000 * 60 * 60)).toString()
      );
      // Count the minutes
      this.minute = parseInt(
        ((timeLag % (1000 * 60 * 60))/(1000 * 60)).toString()
      );
      // Count the seconds
      this.second = parseInt(((timeLag % (1000 * 60)) / 1000).toString());
      this.countDown(); }}// A pulsing countdown
  countDown() {
    if (this.second - 1 < 0) {
      if (this.minute - 1 < 0) {
        if (this.hour - 1 < 0) {
          if (this.day - 1 < 0) {
            clearTimeout(this.timeId);
            return;
          } else {
            this.day--;
            this.hour = 23;
            this.minute = 59;
            this.second = 59; }}else {
          this.hour--;

          this.minute = 59;
          this.second = 59; }}else {
        this.minute--;
        this.second = 59; }}else {
      this.second--;
    }
    this.timeId = setTimeout(this.countDown, 1000);
  }
// Remember to remove the timer when destroying the page
beforeDestroy() {
    clearTimeout(this.timeId);
  }

Copy the code