當轉換NSString NSDate它給了我錯誤的結果。
NSDateFormatter * formatter = [NSDateFormatter new];
[formatter setDateFormat:@"yyyy-MM-dd"];
NSString * currentDateString = [formatter stringFromDate:[NSDate date]];
NSDate *currentDate = [formatter dateFromString:currentDateString];
currentDateString值是 「2017年1月1日」 的currentdate值越來越18:30:00 2016年12月31日+0000
有人驚喜,我是什麼東西錯在對話中?
它返回UTC時間,所以我只好把它轉換成你的本地時間 –
你需要包括時區信息的http:/ /stackoverflow.com/questions/1268509/convert-utc-nsdate-to-local-timezone-objective-c – Flexicoder
您必須爲此設置timeZoneWithName屬性...... –