I am new with EKEventKit and I am trying to create an event in calendar using EKEvent. It works fine but after saving the event when I check again the event date it gets one day earlier.
I am writing my code here with output. Please have a look
EKEventStore *eventStore = [[EKEventStore alloc]init];
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
// set Event Title and Notes
event.title = @"My New Event";
event.notes = @"New event notes are added by azeem";
// set Event Start and End date here
NSLog(@"before saving Date: %@",[NSDate date]);
event.startDate = [NSDate date];
event.endDate =[NSDate date];
// set Evet other Properties here
event.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
event.calendar = [eventStore defaultCalendarForNewEvents];
event.allDay = YES;
[eventStore saveEvent:event span:EKSpanThisEvent error:&error];
NSLog(@"After saving Date: %@",event.startDate);
OUTPUT ::
Before Saving Date : 2013-04-10 08:00:40 +0000
After Saving Date: 2013-04-09 00:00:00 +0000
We can see here that there is 1 Day before. but they should be same.
I hope I am very much clear with my question, but still if any question, you can ask me.
thanks in anticipation.