Reputation: 442
I m sorry stackoverflow is full of dateformatter questions but i m having a really hard time to get a string into a NSDate
.
This is the String i receive:
2014-12-22T06:49:40+0000
And this is how i m trying to format it and get it to a NSDate
:
NSString *time = @"2014-12-22T06:49:40+0000";
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd'T'hh:mm:ss'Z'"];
[df setTimeZone:[NSTimeZone systemTimeZone]];
NSDate *myDate = [df dateFromString:time];
Unfortunately myDate is always nil
.
Am i missing somtheing or is my formatting simply wrong?
Thanks in advance
Upvotes: 0
Views: 47
Reputation: 243146
You've wrapped your final Z
in single quotes, which means you want it to be a literal Z
character, but no such character exists in your time string. Removing the single quotes means it would be looking for a timezone offset, like you want.
Upvotes: 1