I am converting seconds into hours minutes and seconds.
and method is as follows
for (int i=0; i<24; i++) {
int remain = 60/6;
int hrs = i;
for (int j=0; j<6; j++) {
if (remain == 60 ) {
remain=0;
NSLog(@"%d:%d",hrs+1,remain);
if (hrs==24) {
NSLog(@"%d:%d",hrs,remain);
}
}else{
NSLog(@"%d:%d",hrs,remain);
remain = remain+10;
}
}
}
I want to divide the time (24 hrs ) into slots of 10 minutes that me i need to display
00:10 ,00:20,…..up to 23:40,23:50 .
but i want to display the time slots with 00:10 to 23:50 but the out put is as follows 0:10
simply need display double zeros
0:20
0:30
0:40
0:50
1:0
1:10
1:20
1:30
1:40
1:50
2:0
2:10
2:20
2:30
2:40
2:50
3:0
You have to use a different format for displaying leading zeros. This will display at least 2 digits for hours, filling up with 0 if the digits would be less:
NSLog(@"%02d:%d",hrs, remain)