I am working in an iPhone application using NSDateFormatter. I get time from a web service, for example, "00:00:00", "16:00:00","15:30:00" and so on . I need to convert this time to if the time is "00:00:00" to "12 AM" , if the time is "16:00:00" to "4 PM" , if the time is "15:30:00" to "3.30 PM" . I used the code below, but when I have the pass "16:00:00" the date returns null .
NSString *dats1 = @"16:00:00"; NSDateFormatter *dateFormatter3 = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter3 setDateStyle:NSDateFormatterMediumStyle]; [dateFormatter3 setDateFormat:@"hh:mm:ss"]; NSDate *date1 = [dateFormatter3 dateFromString:dats1]; NSLog(@"date1 : %@", date1); **
When I go through โ00:00:00โ, it returns โ12 AMโ correctly. Can someone help me solve this problem? Thanks in advance.
ios time iphone nsdateformatter
Gopinath Jul 23 '12 at 7:32 2012-07-23 07:32
source share