我需要来自两个NSDate等的结果:
首先是NSDate,例如:2011-02-20 00:00 AM每个iPhone时区都有什么
秒。 NSDate例如:2011-03-20 23:59 PM每个iPhone时区都有什么
我真的和工具混淆了! 我做了如下:
NSCalendar *gCal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *gComponents = [[NSDateComponents alloc] init];
gComponents.day = gDayEventChecker;
gComponents.month = gMonthEventChecker;
gComponents.year = gYearEventChecker;
gComponents.hour = 0;
NSDate *first = [gCal dateFromComponents:gComponents];
NSCalendar *gCal2 = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *gComponents2 = [[NSDateComponents alloc] init];
gComponents2.day = gDayEventChecker2;
gComponents2.month = gMonthEventChecker2;
gComponents2.year = gYearEventChecker2;
gComponents2.hour = 23;
gComponents2.mintue = 59;
NSDate *sec = [gCal2 dateFromComponents:gComponents2];
结果不正确!
第一名:2011-02-20 01:30:00 +0000 第二名:2011-03-20 01:30:00 +0000