1 person found this helpful
There are a variety of issues with your approach that you need to work out.
If you want the milliseconds to show up as two digits only, that itself is a problem because there are 1000 of them in a second. So you may want to clear up what you mean/intend there. In practical terms, showing 2 digits would mean you are displaying the hundredths of a second, not msec.
What you are showing in your result are the total milliseconds that result from the getTimer() call. You only need to display the number of them that are not going to be represented by the seconds (et al, as your seconds and minutes suffer the same issue). And the number of them that represented are the remainder after you divide by 1000.
So if you have 63123 msecs as a result of the getTimer(), then you only want the 123 portion of that as your msec display. The rest of it gets worked into the sec, min, and hour elements.
You can use the modulus operator to detemine what that remainder is using code...
msecToDisplay = msec%1000;
And you would have to do similar things for your seconds, and minutes. As it is now, you will end up showing more than 60 seconds and more than 60 minutes in your display.
While someone might come along and hand you a solution to this, I think it will be a great learning experience for you if you try to work it out yourself.
Thank you very much sir for the reply.
here is a link that give the idea of having milliseconds in 2 digit
I hope I didn't violate on the rules by posting the link.
You didn't violate any rules (don't know of too many except the ones about being polite, etc), but you neglected to say what to look for. I did eventually find what I think you are talking about and what is displayed there makes no sense. I think it is just a visual prop as it never seems to go above 20-something. And seeing as how the times end up as exact values, it is definitely rigged.
As I mentioned already 1000 msec = 1 sec, and you can only get as high as 99 with two digits, so you need to think thru what you want to do.
I got it work tnx.