iphone - String to NSDate -
iphone - String to NSDate -
i trying convert string date. have used next code. getting wrong date.
thanks,
nsstring *datestring = [nsstring stringwithformat:@"12-07-2011"]; //nsstring *datestring = [nsstring stringwithformat:@"%d-%d-%d", selecteddate.day, selecteddate.month, selecteddate.year]; nslog(@"%@",datestring); nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setlocale:[nslocale currentlocale]]; [dateformatter settimezone:[nstimezone localtimezone]]; [dateformatter setdateformat:@"dd-mm-yyyy"]; nsdate* d = [dateformatter datefromstring:datestring]; nslog(@"%@",d); uialertview *alert = [[uialertview alloc] initwithtitle:@"selected date" message: [nsstring stringwithformat:@"%@",d] delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alert show]; [alert release];
the problem using min , not month. m
[dateformatter setdateformat:@"dd-mm-yyyy"];
unicode date format patterns
iphone objective-c nsdate
Comments
Post a Comment