0
我想得到一個日期,表示中午格林尼治標準時間週期性本地通知。絕對格林尼治標準時間日期在iPhone上
我需要這個本地通知,在任何使用該應用程序的人的確切時刻開火。然而
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
[dateComps setHour:12];
[dateComps setMinute:0];
[dateComps setMonth:1];
[dateComps setDay:1];
[dateComps setYear:2010];
NSDate *localDate = [calendar dateFromComponents:dateComps];
NSTimeInterval timeZoneOffset = [[NSTimeZone defaultTimeZone] secondsFromGMT];
NSTimeInterval gmtTimeInterval = [localDate timeIntervalSinceReferenceDate] - timeZoneOffset;
NSDate *gmtDate = [NSDate dateWithTimeIntervalSinceReferenceDate:gmtTimeInterval];
localNotification.fireDate = gmtDate;
這不是工作,:
到目前爲止,我想這一點。有什麼建議麼?
編輯:: 將這項工作,如果我不指定在notfication時區:
localNotification.fireDate = [NSDate dateWithTimeIntervalSince1970:1284483600];
這與我上面的編輯類似,其中你剛剛創建一個日期與時代秒代表這個時間?該死的,誰會想到這個日子可能會非常棘手? – DexterW 2010-09-14 01:30:47
是的,我認爲你的編輯也會起作用。在格林尼治標準時間1970年,每個人都會得到相同的抵消,所以每個人都會同時開火。要麼工作(我會想......) – 2010-09-14 01:39:46
是的,它的工作。 – DexterW 2010-09-15 18:58:19