Jump to content
  • Advertisement

Archived

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

foonk

re-formating time

This topic is 5967 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!