I am trying to set an NSDate
from a string. The format of the string looks like this (RFC 2822):
Tue, 09 Jun 2015 06:09:38 +0000
The code I am using is:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier: @"en_US_POSIX"];
dateFormatter.dateFormat = @"EEE, dd MMM yyyy hh:mm:ss Z";
NSDate *dateString = [dateFormatter dateFromString:self.time];
But dateString
always returns a nil. self.time
definitely contains the string for the time.
You possibly need to set timezone. [dateFormatter setTimeZone:[NSTimeZone defaultTimeZone]];