I use the code below to retrieve a date only from NSDate. What am I doing wrong?
NSDate* now = [NSDate date]; NSLog(@"Now Date %@",now); NSDateFormatter *format = [[NSDateFormatter alloc] init]; format.dateFormat = @"dd-MM-yyyy"; NSString *stringDate = [format stringFromDate:now]; NSDate *todaysDate = [format dateFromString:stringDate]; NSLog(@"Today Date without Time %@", todaysDate);
Log:
2014-06-21 12:27:23.284 App[69727:f03] Now Date 2014-06-21 19:27:23 +0000 2014-06-21 12:27:23.285 App[69727:f03] Today Date without Time 2014-06-21 07:00:00 +0000
Why do I get: 07:00:00 +0000 at the end?
I would like to get NSDate in the following format:
2014-06-21 00:00:00 +0000
Availability 0 for time, seconds, etc. it does not matter.
source share