-1

I want to know how to do some simple equations in my iOS app, if anyone could point me in the right direction that would be wonderful!

I need to know how to convert an NSNumber that represents minutes to an NSString which represents hours and minutes (example: 100 = 1 hour and 40 minutes)

I also want to know if its possible to convert something like 2013-02-08T10:50:00.000 to 10:50AM

Thanks for any tips you guys might have.

Till
  • 27,559
  • 13
  • 88
  • 122
Jon Sullivan
  • 399
  • 2
  • 5
  • 11

1 Answers1

1

For the conversion :

NSNumber *yourNumber = [NSNumber numberWithInt100];

NSInteger hour    = [yourNumber intValue] / 60;
NSInteger minutes = [yourNumber intValue] % 60;
NSString *time_stamp = [NSString stringWithFormat:@"%d hour and %d minutes",hour,minutes];

As the comments suggested you can use NSDateFormatter to format your NSDate.

oiledCode
  • 8,589
  • 6
  • 43
  • 59