Js wrote down the following countdown: the countdown of the day to 10:00 the next day, and the countdown from 0 o'clock to 10 o'clock the next day.

younger brother js is relatively weak, can only write the countdown from the current time to a given time, looking for Daniel solution, will study hard, thank you.

Mar.07,2021


var s = 1000,
    m = 60 * s,
    h = 60 * m,
    d = 24 * h,
    tick_time = 1000,
    timezone = new Date().getTimezoneOffset() * m;

var getDayTime = function(t) {
  t = t.split(':');
  return t[0] * h + t[1] * m;
}

var getNextClock = function(clockTime, resetTime, now) {
  var result = now_d = parseInt(now / d, 10) * d + timezone;
  now_d_t = now - now_d;
  if (now_d_t > resetTime) {
    result += d;
  }
  return result + clockTime;
};

var before = 0,
  resetTime = getDayTime('00:00'),
  clock24 = getDayTime('10:00');

var tickHandler = function() {
  var now = Date.now();
  if (now - before > tick_time) {
    var nextClock = getNextClock(clock24, resetTime, now);
    var diff = nextClock - now;
    var floor = Math.floor;
    var diif_readable = [
      floor(diff / d),
      floor((diff % d) / h),
      floor((diff % h) / m),
      floor((diff % m) / s)
    ];
    console.log(diif_readable);
    before = now;
  }
};
var handler = setInterval(tickHandler, tick_time/10);
tickHandler();
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-1eae49a-47f85.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-1eae49a-47f85.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?