I have refer previous examples from here. But still problem in null value.
String Value is :==> strDate = “09-05-2012 00:00:00”
I want output as :==> May 09, 2012
My Code:
NSString *strDateFormat;//[strDate substringWithRange:NSMakeRange(0, 10)];
strDateFormat = [NSString stringWithFormat:@"%@", strDate];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
NSDate *disDate = [df dateFromString:strDateFormat];
[df setDateFormat:@"MMM dd, yyyy"];
strDateFormat = [df stringFromDate:disDate];
lblDate.text = [NSString stringWithFormat:@"%@", strDateFormat];
[df release];
It gives (null) value. Because disDate has (null) value.
Why disDate set to nil..?
Any solution..?
You gotta tell the formatter what format to expect when reading a string, too.