The format of your date @"yyyy-MM-dd'T'HH:mm:ss'Z'" means that it searches for the letter character " Z " at the end of the line. However your line:
@"2011-07-20T23:59:00-07:00"
I donβt see there " Z ", right? Thus, the date is returned as nil , because your string does not match the specified format.
According to the date formatting documentation , you are probably looking for a format string:
@"yyyy-MM-dd'T'HH:mm:ssZZ"
However, even this may not work, because if you notice that your source line has a colon (" : ") between the hours and minutes of the time zone offset. There is no time zone specifier that takes this into account. If this is really a format in which ROR returns a date, then ROR is wrong.
source share