Archived

This topic is now archived and is closed to further replies.

foonk

re-formating time

Recommended Posts

hi, i was woundering if theres an easy way to reformat milliseconds into something like mm:ss or even hh:mm:ss ?? or if theres anywhere you poeple can point me to on he net that night help, thanks.

Share this post


Link to post
Share on other sites
For dates (maybe not quite what you want) -> ctime()

Otherwise, do it by hand
  
unsigned long time = whatever
unsigned short ms = time % 1000;
time /= 1000;
unsigned short s = time % 60;
time /= 60;
unsigned short m = time % 60;
time /= 60;
unsigned short h = time % 24;
time /= 24;
printf( "%u days %02u:%02u:%02u.%03u", time, h,m,s,ms );

Share this post


Link to post
Share on other sites