views:

137

answers:

1

Full Disclosure: I am a mathematical moron

int hours = totalSeconds / (60 * 60);
int minutes = (totalSeconds / 60) % 60;
int seconds = totalSeconds % 60;
//int milliseconds ???
calculatedExposureTime.text = [NSString stringWithFormat:@"%02d:%02d:%02d:%02d", hours, minutes, seconds, milliseconds];

Say totalSeconds was a fraction of a second (0.000156), how do I calculate and display time down to the millisecond?

+1  A: 
...
double seconds = fmod(totalSeconds, 60.0);
... [NSString stringWithFormat:@"%02d:%02d:%06.3f", hours, minutes, seconds];

BTW, 0.000156 is less than one millisecond, so it will display as 0.000.

Marcelo Cantos
Thank you Marcelo, told you i was a bit of a moron. Appreciate your help
Ronn