gpt4 book ai didi

iphone - 为什么 NSDateFormatter 无法解析 ISO 8601 格式的日期

转载 作者:IT王子 更新时间:2023-10-29 08:17:10 27 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Converting an ISO 8601 timestamp into an NSDate: How does one deal with the UTC time offset?

我使用 rails 作为后端,默认日期输出是 2008-12-29T00:27:42-08:00

但经过我的研究,NSDateFormatter 无法支持它,除非我将日期更改为 2008-12-29T00:27:42-0800

这是我用来解析 ISO 8601 日期的代码,但它不起作用

NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
NSLog(@"%@", [dateFormatter dateFromString:@"2008-12-29T00:27:42-08:00"]);

有什么想法吗?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com