I have a date string, for example:
2012-04-09T23:57:44.070Z
My date format is:
[dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
But it’s returning nil. What’s wrong with my date format?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t need to be so aggressive about escaping
-and:. Also, your seconds characters are wrong. You should be using:This logs:
If you don’t set the timezone on the date formatter, it’s going to assume you mean whatever time zone the device is in right now, and not the GMT timezone (which is what the
Zis implying).