3 回答

TA貢獻(xiàn)2021條經(jīng)驗(yàn) 獲得超8個(gè)贊
如果您以iOS的一種樣式存儲(chǔ)日期,則使用此方法更容易且更容易出錯(cuò):
// Define a date formatter for storage, full style for more flexibility
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterFullStyle];
[dateFormatter setTimeStyle:NSDateFormatterFullStyle];
// Use today as an example
NSDate *today = [NSDate date];
// Format to a string using predefined styles
NSString *dateString = [dateFormatter stringFromDate:today];
// Format back to a date using the same styles
NSDate *todayFromString = [dateFormatter dateFromString:dateString];
- 3 回答
- 0 關(guān)注
- 581 瀏覽
添加回答
舉報(bào)