Need help in timer

I'm making a timer, but I want it to display the countdown from hours to minutes to seconds like a real clock. But I can't seem to find the right formula to display the minutes. When I enter hours, it only displays the literal minutes. For example I input 1:00:00 it displays 00:3540.

void showCountdown()
{
 char timest[6];

 lcd.setCursor(0,0);
 lcd.print("********************");
 lcd.setCursor(0,1);
 lcd.print("** COUNTING DOWN **");
 lcd.setCursor(0,2);
 lcd.print("** ");
 sprintf(timest, "%d:%d:%.2d", (timerSeconds/3600), (timerSeconds - (timerSeconds/60)), (timerSeconds - ((timerSeconds/60)*60)));
 lcd.print(timest);
 lcd.print(" **");
 lcd.setCursor(0,3);
 lcd.print("********************");

}

This might help

void ClockDisplay()
{
  sprintf(currentTime, "%02d:%02d:%02d", hour(), minute(), second());
  sprintf(currentDate, "%02d/%02d/%04d", day(), month(), year());

  Blynk.virtualWrite(V0, currentTime);    //Send time to TIME widget
  Blynk.virtualWrite(V1, currentDate);    //Send date to DATE widget
}

For help with code, it is very important that you post all of the code.

  int second = timerSeconds % 60;
  int minute = (timerSeconds / 60) % 60;
  int hour = timerSeconds / 3600u;
  sprintf(timest, "%d:%02d:%02d", hour, minute, second);
  lcd.print(timest);

Hello johnwasser

How to add a leading "0" for hour?

grafik

If you want it to be a two-digit field like minutes and seconds, use "%02d" like for minutes and seconds.

Many thanks for your help. :+1:

grafik