I'm trying to get a date that represents noon GMT for a recurring local notification.
I need this local notification to fire at the exact moment to anyone using the app.
So far, I'm trying this:
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;
This isn't working, however. Any suggestions?
Edit:: Will this work if I don't specify a time zone on the notfication:
localNotification.fireDate = [NSDate dateWithTimeIntervalSince1970:1284483600];