I was trying to add an ical event using this code.
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event = [EKEvent eventWithEventSto开发者_JAVA百科re:eventStore];
event.title = title;
event.startDate = date;
event.endDate = [[NSDate alloc] initWithTimeInterval:5000 sinceDate:event.startDate];
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
Where date is something 2011-09-30 20:30:00 +0000
The event go added on date 1st October with time 2 AM, it is very strange.
I need help.
Thanks.
You are not taking in account the timeZone.
2011-09-30 20:30:00 +0000 the +0000 means GTM, if you set a to plus 4 hours you will get 2011-10-01 02:30:00 +0400 which is the date you are getting.
精彩评论