Time not working?

I have the following code which displays current esplayed time in LCD, it hangs after one minuter on “:059” displayed in LCD. Why?

Code:

#include <LiquidCrystal.h>


LiquidCrystal lcd(12,11,5,4,3,2);

void setup()
{

  
  lcd.begin(16, 2);

  lcd.clear();


  
  lcd.print("Welcome Ashesh");

}

void loop()
{


  lcd.setCursor(0,1);


lcd.print("Time ");
int sec=millis()/1000;
int hr,minu = 00;

if(sec>59){
  sec=0;
  minu++;
}

if(minu>59){
  minu=0;
  sec=0;
  hr++;
}

lcd.print(hr+":");lcd.print(minu+":");lcd.print(sec);

}

Tried:

 lcd.setCursor(0,1);



lcd.print("Time ");
int hr,minu,sec=0;

if(sec>59){
  sec=0;
sec=millis()/1000;
}else{
sec=millis()/1000;
}
if(minu>59){
  minu=0;
minu=millis()/60000;
}else{
minu=millis()/60000;
}

hr=millis()/3600000;

lcd.print(hr+":");lcd.print(minu+":");lcd.print(sec);

LCD showing time in soconds not minu or hr, like this "time : 900" After this it shows "Time: Welcome As"

lcd.print(hr+":");lcd.print(minu+":");lcd.print(sec);

I don't have an LCD connected at the moment but does this work do this when hr and minu are ints ?

Print the values as two digits, or else clear the line before you overwrite it? Or write some spaces after the time value?

Currently you are probably leaving some trailing junk on the output whenever the character count decreases.

lcd.print(hr+":");

This ain't java. You can't concatenate them with a + like that.

lcd.print(hr);
lcd.print(":");

Is there any reason not to use sprintf?

AWOL: Is there any reason not to use sprintf?

I just stared Ardunio yesterday, How can i know? :)

The sprintf() function lets you format a series of variables and text in an array so that the resulting array can be printed. Google is your friend on how to do it.