开发者

Convert seconds to formatted time like 12:59? [duplicate]

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

Possible Duplicate:

Co开发者_如何学Pythonnvert seconds to days, minutes, and hours in Obj-c

How to do it in Objective-C

For example:

349200 seconds??


Add the below function and pass "seconds" value in this function.

- (void)displayTimeWithSecond:(NSInteger)seconds   
        {  
        NSInteger remindMinute = seconds / 60;
NSInteger remindHours = remindMinute / 60;

NSInteger remindMinutes = seconds - (remindHours * 3600);
NSInteger remindMinuteNew = remindMinutes / 60;

NSInteger remindSecond = seconds - (remindMinuteNew * 60) - (remindHours * 3600);

NSLog(@"Hours = %@", [NSString stringWithFormat:@"%02d",remindHours]);
NSLog(@"Minute = %@", [NSString stringWithFormat:@"%02d",remindMinuteNew]);
NSLog(@"Seconds = %@", [NSString stringWithFormat:@"%02d",remindSecond]); 
}

Here, displayTime is Label.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜