View Full Version : printing time in HH:MM:SS:MS format

10-24-2007, 12:58 AM
hi all,

i want to print time in HH:MM:SS:MS<millisec> format... how to do??

Thanks in advance....


10-24-2007, 01:32 AM
Where are you reading time from, and in what format?

Apart from milliseconds, I would use time.h and strftime().

10-24-2007, 01:42 AM
using date command im reading time.

10-24-2007, 01:03 PM
Well then look at the date man page. Something like this

date '+&#37;H:%M:%S'
gives you HH:MM:SS. I don't see an option for milliseconds.

Why are you using the date command, anyway? It's not very portable, and depending on how you are executing it, probably slow.

Consider using some functions from time.h. There are also unportable Linux functions that return milliseconds, but I can't recall their names at the moment.