gpt4 book ai didi

ios - 转换日期格式返回错误的日期xcode

转载 作者:行者123 更新时间:2023-11-29 11:43:08 26 4
gpt4 key购买 nike

<分区>

我想将日期从 23 May, 2017 转换为 23-05-2017

我已尝试使用以下代码,但它返回 25-12-2016

NSDateFormatter *oldFormatter = [NSDateFormatter new];
[oldFormatter setDateFormat:@"dd MMM, YYYY"];
NSDate *oldDate = [oldFormatter dateFromString:dateStr];

NSDateFormatter *newFormatter = [NSDateFormatter new];
[newFormatter setDateFormat:@"dd-MM-YYYY"];

我正在使用 Xcode 8.2.1。谢谢。

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