我想試着去創造的NSDate的對象這樣混淆的NSDate
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
// [gregorian setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
NSDateComponents *weekdayComponents = [gregorian components:(NSDayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSMinuteCalendarUnit)fromDate:[NSDate date]];
NSInteger day = [weekdayComponents day];
NSInteger month = [weekdayComponents month];
NSInteger year = [weekdayComponents year];
NSDateComponents *timeZoneComps=[[NSDateComponents alloc] init];
[timeZoneComps setDay:day];
[timeZoneComps setMonth:month];
[timeZoneComps setYear:year];
[timeZoneComps setHour:00];
[timeZoneComps setMinute:00];
[timeZoneComps setSecond:01];
m_currentDate = [gregorian dateFromComponents:timeZoneComps];
當我登錄了的currentdate,我得到這個
"2014-07-07 06:00:01 +0000"
如果我保存這plist中我得到這個
07-Jul-2014 11:30:01 am
如果我使用 「UTC」 作爲時區
我把它作爲
"2014-07-07 00:00:01 +0000"
和裏面的plist它顯示爲
07-Jul-2014 5:30:01 am
我不理解正在發生的事情,任何人可以幫助我這個
我想知道,如果我不設置任何時間區將使用什麼時間區?
我們是否需要將UTC明確設置爲timeZone或需要使用systemTimeZone。
你想要的時區取決於,錯誤,你想要什麼時區。日期/時間代表什麼? – trojanfoe
對不起,我沒有得到你的問題,你需要什麼信息? – Ranjit
你是什麼意思「保存到plist」?你怎麼保存它? – Fogmeister