Date formatter for a certain format of date

你离开我真会死。 提交于 2021-02-08 07:33:51

问题


I might missing something, but I can't compose proper date formatter string for the date:

2016-01-14T10:24:26+0000

What is 'T' here? and how to include timezone?

My string does not work: @"yyyy-MM-dd'T'hh:mm:ss Z"


回答1:


You have to use 'T' in single quotes like below format to retrive string ftom date:

yyyy-MM-dd'T'hh:mm:ssZ

Let me know.




回答2:


NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'";     
NSDate *yourDate = [dateFormatter dateFromString:myString];


来源:https://stackoverflow.com/questions/34765304/date-formatter-for-a-certain-format-of-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!