Convert seconds to formatted time like 12:59? [duplicate]
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.
精彩评论