Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Parse Date using NSDateFormatter

I am fetching a RSS, in which i receive the following Date stamp:

2010-05-10T06:11:14.000Z

Now i am using NSDateFormatter to parse this datetime stamp.

[parseFormatter setDateFormat:@"yyyy-MM-dTH:m:s.z"];

But its not working fine if just remove the time stamp part it works for the date [parseFormatter setDateFormat:@"yyyy-MM-d"]; But if i add the rest of the stuff it returns nil.

Any idea ?

Thanks in Advance....

like image 962
Ansari Avatar asked May 10 '10 06:05

Ansari


1 Answers

You need to parse zero padded values for d, H, m, s

You need to escape the literal T as 'T'

You need to parse the fractional part of the seconds with SSS

You can accept a literal Z with 'Z' or use uppercase Z to try and parse the timezone but RSS uses separate standard.

@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

Date Format Patterns

like image 68
drawnonward Avatar answered Oct 13 '22 11:10

drawnonward