On Jul 13, 2011, at 8:21 PM, Tonny wrote:
> i met a dateFromString issue, is there something wrong?
> NSString *dateString = @"2011-07-14 09:09:11";
> NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
> [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
> NSDate *date = [formatter dateFromString:dateString];
> [formatter release];
> NSLog(@"Date : %@",date);
> but i got ----------> Date : 2011-07-14 01:09:11 +0000
Your NSLog isn't being asked to use the date formatter that you made, it's using NSDate's -description method instead. This will give you what you want:
NSLog( @"Date: %@", [formatter stringFromDate:date] );
PS - as a minor note, this question is off-topic for this list and probably best suited for email@hidden, since it's a cocoa api question.
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden