I faced with strange problem while converting NSString value of date to NSDate instance. It looks like Great Harry Potter visited my code.
I receive date string from server as 24-th date format: "2011-11-15 11:44". My iPhone has 12-th date format in settings. When I try to convert that string to NSDate I can see that date value is equal to NIL. If I switch settings to 24-th date format it works fine. This is my code:
NSString * sDate = @"2011-11-15 11:44";
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm"];
[df setTimeZone:[NSTimeZone localTimeZone]];
NSDate * pDate = [df dateFromString:sDate];
As result, pDate is NIL. But, if I run this code on iPod Touch I can see wrong date value in 12-th format instead NIL. I can't understand a problem. Could you help me please?
Thanks.