Hi i’m trying to format my NSString. But its not working. I tried all the answers which i got in stackoverflow, But nothing works for me.
NSLog(@"log 1: %@ %@", [dealDetailsDict objectForKey:@"DealDateViewed"], [[dealDetailsDict objectForKey:@"DealDateViewed"] class]);
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSLog(@"log 2: %@ %@", [df stringFromDate:[dealDetailsDict objectForKey:@"DealDateViewed"]], [df dateFromString:[dealDetailsDict objectForKey:@"DealDateViewed"]]);
I don’t know what is the problem is here, both stringFromDate and dateFromString returning nil. This is my NSLog.
log 1: 2013-01-09 10:02:45 +0000 __NSCFString
log 2: (null) (null)
I want to display date like 31-12-2010. So i set,
[df setDateFormat:@"dd-MM-yyyy"];
Here my problem started.
Use below functionality for date format…