0

Hi I'm trying to format a string so that I am able to get the system time to be HH:MM:SS:MM(Milliseconds)

I've written this

SYSTEMTIME time;
GetLocalTime(&time);
line.Format("%02d:%02d:%02d:%02d \n" ,time.wHour, time.wMinute, time.wSecond, time.wMilliseconds);

My problem is I get something like this for example: 10:17:30:210

I really don't want the 3rd digit on the millisecond how can I truncate it to only two?

user2134127
  • 135
  • 1
  • 2
  • 9
  • 1
    It would be very odd to show "21" - because it's not 21, it's 210. 21 would be centiseconds, not milliseconds. This is pretty much *bound* to cause confusion... – Jon Skeet Jun 20 '13 at 14:20
  • What language is this? C#? Please [edit] the question and add the appropriate tag. – Bernhard Barker Jun 20 '13 at 14:30

1 Answers1

0

You can quite simply divide by 10 - time.wMilliseconds/10.

SYSTEMTIME time;
GetLocalTime(&time);
line.Format("%02d:%02d:%02d:%02d\n" ,time.wHour, time.wMinute, time.wSecond,
            time.wMilliseconds/10);
Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138