Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个(Ruby on Rails 站点的)API,它返回 JSON 数据,日期时间格式如下:
2011-01-21T18:05:41Z
我在 NSString 中有这个,我想用它做一个 NSDate。我怎样才能做到这一点?
尝试:
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
NSDate *theDate = [dateFormatter dateFromString:@"2011-01-21T18:05:41Z"];