Serial output of hours, minutes etc.

As part of Serial Monitor output from my program I would like to be able to date individual lines. For example, I would like to be able to print the current time in the format HH:MM:SS. I cannot identify a likely library in the ones available through the IDE.

Apart from writing a function to convert from millis(), what is available?

If you want the date and actual time-of-day I reckon you need to use a Real Time Clock (RTC) like one of these.

You can't have been looking very hard.

vagulus: Apart from writing a function to convert from millis()

That's OK for a timer, but is really the clock of last resort. http://bildr.org/2011/03/ds1307-arduino/

Thanks to you two and I see what your devices are about. I don't think I need real time-of-day, just elapsed time will be fine for this app. Is a written function the best solution?

How accurate do you need the elapsed time to be and how long is the longest period that will be displayed ?

The Arduino is really not very good at keeping accurate time on its own but converting the elapsed time since an event occurred from milliseconds to HH:MM:SS is not difficult.

vagulus: I don't think I need real time-of-day, just elapsed time will be fine for this app. Is a written function the best solution?

Some ideas here.