开发者

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

开发者 https://www.devze.com 2023-04-02 11:09 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: NSNumber of seconds to Hours, minutes, seconds开发者_Python百科
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

精彩评论

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