开发者

How to convert a large integer, containing an amount of milliseconds into Min:Sec:Mili Objective-c [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

NSNumber of seconds to Hours, minutes, seconds 开发者_Python百科

I have a large number that represents milliseconds.

I would like to format it out into Minutes: Seconds : Milliseconds;

Could anyone help me achieve this?


Convert to double, then scale to seconds. Then use NSDate dateWithTimeIntervalSinceReferenceDate (or NSDate dateWithTimeIntervalSince1970) to convert to an NSDate. From there you can format any number of ways with NSDateFormatter.

You can also, of course, simply use modular division:

int milliseconds = timeValue % 1000;
int temp = timeValue / 1000;
int seconds = temp % 60;
int minutes = temp / 60;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜