ios linux时间戳转时间,将UNIX时间戳转换为数据 – iOS
我有一個iOS應用程序,它解析數據的
JSON提要.在這個數據中有一些UNIX時間戳,我存儲在NSString中.我想要做的是將這些時間戳轉換為日期(月和日).但是我試圖在沒有自己進行任何劃分的情況下這樣做,因為從我在網上看到的,你應該總是使用Apple的API進行轉換以獲得準確的結果.
但是我的代碼無效,我收到此錯誤:
Terminating app due to uncaught exception 'NSInvalidArgumentException',reason: '-[__NSCFNumber length]: unrecognized selector sent to instance
這是我的代碼:
NSString *time_string = [timestamps objectAtIndex:indexPath.row];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [formatter dateFromString:time_string];
cell.dateOfPub.text = [NSString stringWithFormat:@"%@",date];
我不明白我做錯了什么.任何幫助將不勝感激.
謝謝,丹
總結
以上是生活随笔為你收集整理的ios linux时间戳转时间,将UNIX时间戳转换为数据 – iOS的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux安装manjaro创建分区失败
- 下一篇: 重启openssl服务linux,Ngi