the following is a countdown, but there is no processing, there is a 00 situation, I thought that I could not find the entry point to solve this problem, so it is like asking for advice on how to deal with this.
example of 00 situation:
for example, when the countdown is 09 to 59, it should be 09 to 58, but it is 09:59:00
setTimeFunc = (time) => {
const aimTime = new Date(("2018-5-24 09:30:00").replace(/-/g, "/")).getTime();
const currentTime = new Date().getTime();
// const days = null;
// const hours = null;
// const seconds = null;
const diffTime = aimTime - currentTime;
const years = new Date(aimTime).getFullYear() - new Date().getFullYear();
const month = new Date(aimTime).getMonth() - new Date().getMonth();
if (years === 0) {
if (month === 0) {
const days = Math.floor(diffTime / (1000 * 60 * 60 * 24));
const hours = Math.floor((diffTime - (days * 1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((diffTime - (days * 1000 * 60 * 60 * 24) - (hours * 1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((diffTime - (days * 1000 * 60 * 60 * 24) - (hours * 1000 * 60 * 60) - (minutes * 1000 * 60)) / 1000);
console.log(hours);
this.setState({
days: days > 9 ? days : "0" + days,
hours: hours > 9 ? hours : "0" + hours,
minutes: (minutes) > 9 ? minutes : "0" + minutes,
seconds: seconds> 9 ? seconds : "0" + seconds
});
}
}