In my app, i am taking date and time in to string " 2013-06-11 10:15:00 +0000 " like this, but how can i convert this string into date format. I tried like below code but i am getting error in converting.
NSString *string=@"03-05-2014";
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"dd-MM-yyyy"];
NSDate *dateFromString = [dateFormatter dateFromString:string];
Would you please help me in this problem?
Try to do this:
NSDate *dateFromString = [f dateFromString:string];
You have to set the same date format in which the (string or date)contains, otherwise the date is returned by
NSDateFormatterwill be nil.