- Home /
Count DownTimer hours issue
I have a countDown Timer , and the TimerLabel which shows the start of time , i have options for different times , everything shows up fine on the timer label(ex. if i pick 30 minutes , the label shows 30:00 as for other times ) except for 60 minutes it shows up 0 and decreases properly the next instance to 59:59 . I'm not able to find the reason behind this. This is my function to decrease the time .
void DecreaseCountDownTime()
{
TimeSpan ts = TimeSpan.FromSeconds(countDownTimer);
countDownTimer-- ;
if (ts.Minutes < 1.0) {
if (ts.Seconds < 10) {
timerLabel.text = string.Format (" {0:0}", ts.Seconds);
} else {
timerLabel.text = string.Format (" {0:00}", ts.Seconds);
}
}
else if (ts.Minutes >= 1.0 && ts.Minutes < 10.0){
timerLabel.text = string.Format (" {0:0}:{1:00}", Mathf.Floor (ts.Minutes), ts.Seconds);
}
else if (ts.Minutes >= 10 && ts.Minutes < 60 ) {
timerLabel.text = string.Format (" {0:00}:{1:00}", Mathf.Floor (ts.Minutes), ts.Seconds);
} else {
timerLabel.text = string.Format (" {0:00}:{1:00}:{2:00}",ts.Hours, Mathf.Floor (ts.Minutes), ts.Seconds);
}
}
Comment
@sourav13 The if statement at line # 6 is false when you set countdown = 60. It should be
if (ts.$$anonymous$$inutes <= 1.0)
Your answer
![](https://koobas.hobune.stream/wayback/20220612082631im_/https://answers.unity.com/themes/thub/images/avi.jpg)