TheMaximumWeasel
asked on
NSTimeInterval to minutes and seconds
I have an integer in seconds, that when converted to minutes is less than 60 minutes (So no need to worry about hours). I want to convert the seconds string to a format like this:
int seconds = 352;
...
NSString *time = @"05:52";
NOTE: minutes must have the 0 in front of it if its less than 10 minutes. Same for seconds obviously :)
Max
int seconds = 352;
...
NSString *time = @"05:52";
NOTE: minutes must have the 0 in front of it if its less than 10 minutes. Same for seconds obviously :)
Max
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I can not see why that could be a requirement. You have to create the NSString somehow. So why not using is as I did? However you can use any C function like e.g
char formatted_string_buf[20];
sprintf("formatted_string_ buf, "%0.2d:%02d", minutesAndSeconds.quot, minutesAndSeconds.rem);
then you create the NSString from the C buffer.
Regards
Friedrich
char formatted_string_buf[20];
sprintf("formatted_string_
then you create the NSString from the C buffer.
Regards
Friedrich
Ok, let me clarify it. You question was fully and AFAIKT correctly answered, now you can accept the solution or not. If you like to get another answer then state precicly what can and what can not be used, but in another question.
Friedrich
Friedrich
ASKER
Sorry about the slow response I hadn't got around to checking the question.
ASKER