Reputation: 12007
So this sounds like it should be so simple, yet for me, this code block returns a nil
date:
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
NSDate *newStartDate = [df dateFromString:@"2012-05-11 20:45:00"];
Does anyone have any idea what could be causing newStartDate
to be returned as nil
? df
is valid, the format string appears to be valid. I'm completely stuck here, so any advice would be great!
Thanks!
Upvotes: 0
Views: 226
Reputation: 815
you should use a valid date
its better if you take something like
NSDate *d = [NSDate date];
or it should be 2012-05-11 20:45:00 +0000
your current static date is missing timezone
Upvotes: -2