I have been through all the similar questions, unfortunately non could solve my problem so I asked it. I need my function to return an NSDate
and only date, but my return value contains timing as well, I have tried the setTimeStyle noStyle and every possible solution I could come up with, here is the code:
-(NSDate*)stringToDate{
NSString *dateString = @"01-02-2010";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MM-yyyy"];
NSDate *date;
date = [dateFormatter dateFromString:dateString];
NSLog(@"%@",date);
return date;
}
The output is : 2010-01-31 16:00:00 +0000
What I want: 2010-01-31