NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy"];
NSDate *dateInitial = [dateFormat dateFromString:self.labelDateInitial.text];
NSDate *dateEnd = [dateFormat dateFromString:self.labelDateEnd.text];
NSLog(@"%@", dateInitial);
NSLog(@"%@", dateEnd);
Why i receive null value for both dateInitial and dateEnd ?
in label date is in plain text
nine november 2012
is it correct dd-MM-yyyy ?
If your date string value is
nine november 2012then usingdd-MM-yyyywill not help as its expecting date string as09-11-2012.For month as
november, I think you can useMMMMM, not sure aboutnine.i.e. if
09 November 2012thendd MMMM yyyycan be used.Edit:
To get the date formatted in specific timezone, set the timezone to the format as below:
Use appropriated Timezone string e.g.
EST,PTCetc.