2

Possible Duplicate:
Convert seconds to days, minutes, and hours in Obj-c

How to do it in Objective-C

For example:
349200 seconds??

Community
  • 1
  • 1
elp
  • 8,021
  • 7
  • 61
  • 120
  • http://stackoverflow.com/questions/572049/convert-seconds-to-days-minutes-and-hours-in-obj-c – thelaws Jun 06 '11 at 12:59
  • This is a very similar example: http://stackoverflow.com/questions/4046991/formatting-seconds-into-hhiiss – Jon Jun 06 '11 at 12:59

1 Answers1

10

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.

Nishant B
  • 2,897
  • 1
  • 18
  • 25