In my application I need to get the hour and minute separately:
NSString *currentHour=[string1 substringWithRange: NSMakeRange(0,2)];
int currentHourInNumber=[currentHour intValue];
Consider string1
contains 11:59:13 AM
which is coming from datepicker.
Here if I use above code, it's okay to get hour if it's greater than 9. Else I need to change NSMakeRange(0,1)
to get hour between 1 to 9.
Are there any methods to get the hour, minutes, etc?
Thanks in advance, please provide me sample code.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…