More accurate uptime counter

Hi All,

I am building a meat dryer and want to display the uptime on an LCD,my code below works but the time runs very slow,possibly due to the delay’s being called in the code.
Is there a more accurate way to calculate uptime without using a RTC ?
Super accuracy is not necessary,just a reasonable idea of uptime.
Full code in attachment.
Thanks Dave

void uptime(){

 static unsigned long lastTick = 0; // set up a local variable to hold the last time we moved forward one second          
 // (static variables are initialized once and keep their values between function calls)            
 // move forward one second every 1000 milliseconds            
 if (millis() - lastTick >= 1000) {            
   lastTick = millis();            
 // move forward one minute every 60 seconds            
  if (second >= 60) {            
  second = 0; // reset seconds to zero   


            if (minute >= 60) {            
  minute = 0; // reset minutes to zero

   if (hour >= 24) {            
  hour = 0; // reset hours to zero

Biltong Drier.ino (4.72 KB)

Try this modification. It will eliminate accumulating error.
millis() should be accurate even with the delay().

//lastTick = millis(); 
lastTick += 1000;