请帮我不明显代码的行为日期格式不正确?
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.hour = 15;
dateComponents.minute = 20;
dateComponents.calendar = calendar;
NSDate * endDate = [calendar dateFromComponents:dateComponents];
结束日期为0001-01-01 12点49分43秒+0000。为什么?
由于时区不同,小时值可能不正确。为什么这样奇怪的分钟和秒钟值? 此致敬礼。
如果我不得不猜测,我会说这是由01/01/0001以来日历中积累的闰秒造成的,所以我会尝试设置年份。但我只是做了这个,所以这可能是完全错误的。 –
有趣的...你可以打印日历的时区属性,特别是属性。 'secondsFromGMT'和'abbreviation'。 –
@GuillaumeAlgis好主意! –