In objective-c, how can I convert an integer (representing seconds) to days, minutes, an hours?
Thanks!
Just a bit modification for both compatible with 32 bit & 64 bit. Using NSInteger
the system will automatically convert to int or long basing on 32/64 bit.
NSInteger seconds = 10000;
NSInteger remainder = seconds % 3600;
NSInteger hours = seconds / 3600;
NSInteger minutes = remainder / 60;
NSInteger forSeconds = remainder % 60;
By the same way you can convert to days, weeks, months, years