I am having a date format “16-11-2011”. but I want to convert it into “16 Nov”
I written the code for it but null value generates instead of the format “16 Nov”
for this I have written following code
NSDate *checkIn = [[NSUserDefaults standardUserDefaults]valueForKey:@"CHECK_1"];
NSLog(@"Date: %@",checkIn);
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd MMM"];
NSString *checkInDate = [formatter stringFromDate:checkIn];
NSLog(@"checkInDate:%@",checkInDate);
and the results display by nslog statements are as follows:
Date: 16-11-2011
checkInDate:(null)
so I am not able to convert it into the format which I want
plz help me to solve the problem.
I suspect that
checkInis aNSStringnotNSDate.Therefore, you would have to convert it to a
NSDatefirst and then convert it back to the desired string format.