DateTime to NSDate
How do I convert string 2010-11-19T20:00:00Z
into an NSDate
object?
I've tried using [dateFormatter setDateFormat:@"yyyy-MM-ddTHH:mm:ssZ"]
but it looks like I got the w开发者_Go百科rong custom format style.
PS: I don't care about Timezones. Actually, I want the date to stay in the original (UTC) timezone.
Try using your format string to convert from an NSDate to a string and see what you get. It's easier debugging in that direction than the other.
In this case, looks as though you need to escape the T and Z literals in your pattern. Something like this:
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
精彩评论