Converting NSString to NSDate gives nil [duplicate]

i know this question false in duplicate category & i flagged it as well. but i am answering here with explanation, if in case OP does not get the references .

 NSString *dateString = @"2014-04-30T00:00:00"; //input string
 NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
 [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];// fomatter in your case
 NSDate *date = [formatter dateFromString:dateString];
 NSLog(@"date is%@",date);

 output - date is2014-04-29 18:30:00 +0000

Leave a Comment