Here is a clock sketch that CrossRoads wrote.
I modified it for 24-hour time.
Shouldn't be too hard for you to modify for what you have in mind.
/*
CrossRoads Timeclock
Adapted for 24hr time
by Me! 08SEPT2012
__h__m__s
and leading zeros, too
*/
unsigned long previousTime = 0;
byte seconds ;
byte minutes ;
byte hours ;
void setup()
{
// Preset HHMMSS for 24hr rollover test
// Could jump to a function to set time
// and start
seconds = 45;
minutes = 59;
hours = 23;
Serial.begin (9600);
}
void loop ()
{
// I wonder whether "microseconds"...
if (millis() >= (previousTime))
{
previousTime = previousTime + 1000; // use 100000 for uS
seconds = seconds +1;
if (seconds == 60)
{
seconds = 0;
minutes = minutes +1;
}
if (minutes == 60)
{
minutes = 0;
hours = hours +1;
}
if (hours == 24)
{
hours = 0;
}
if (hours < 10)
{
Serial.print("0");
}
Serial.print (hours, DEC);
Serial.print ("h");
if (minutes < 10)
{
Serial.print("0");
}
Serial.print (minutes,DEC);
Serial.print ("m");
if (seconds < 10)
{
Serial.print("0");
}
Serial.print(seconds,DEC);
Serial.println("s");
} // end 1 second
} // end loop