gpt4 book ai didi

iphone - NString 显示 NSDate 是 000 而不是 iphone 应用程序中的实际日期

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:41:41 25 4
gpt4 key购买 nike

我有一个应用程序,我在其中使用 NSDate 并将其保存在 NSString 中,但是像这样的 NSString 存储 000.000 是我正在使用的代码

NSDate* date = [NSDate date];
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:MM:SS"];

NSString* str = [formatter stringFromDate:date];
NSString*content_AddedTime=str;

NSString *post =[[NSString alloc] init];
post = [NSString stringWithFormat:@"userId=%@&catalogID=%@&content_AddedTime=%@&organizationCode=%@",userId,catalogID,content_AddedTime,organizationCode];

最佳答案

试试这个:

[formatter setDateFormat:@"yyyy/MM/dd HH-mm-ss"];

或者你可以使用:

[formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss ZZZ"];

希望对您有所帮助!

关于iphone - NString 显示 NSDate 是 000 而不是 iphone 应用程序中的实际日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17940126/

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