ios - Get wrong time when adding an event to default calendar in iPhone -
Now I'm working on the calendar application in the iPhone. I'm trying to add an event to the default calendar in iPhone. An incident has been successfully completed in this incident. But I can not add an event to the proper start time The event's start date is quite right, but the time in the default calendar of the iPhone is different. I used the following code. Please help me ..
NSLog (@ "Start Label:% @", startLabel.text); // 2013-03-28 12:03:41 PM
NSLog (@ "end label is:% @", endLabel.text); // 2013-03-28 01: 03: 41 PM NSDF format * Data format = [[NSDet formatted ALLO] INIT]; [DateFormat setDateFormat: @ "yyyy-MM-dd hh: mm: ss a"]; [DateFormat set time zone: [NSTimeZone timezone name: @ "GMT"]]; NSLog (@ "Description:% @", [dateFormat description]); NSDate * sDate = [dateFormat dateFromString: startLabel.text]; NSDate * eDate = [dateFormat dateFromString: endLabel.text]; NSLog (@ "Start Date:% @", SDT); // 2013-03-28 12:03:41 +0000 NSLog (@ "and date is:% @", EDT); // 2013-03-28 13: 03: 41 +0000 self Eveststor = [[Echiststor Elok] Init]; EKEvent * myevent = [Dentist with EKEvent event: self.eventStore]; Myevent.title = titleFld.text; Myevent.location = locFld.text; Myevent.startDate = sDate; Myevent.endDate = eDate; [Myevent setCalendar: [EventStore default calendarForm new events]]; NSError * err; [Self. Investor Save Event: MyVenture Span: EKSpanThisEvent Error: & amp; Err];
Usage [dateFormat setTimeZone: [NSTimeZone systemTimeZone]]; [dateFormat setTimeZone: [NSTimeZone timeZoneWithName: @ "GMT"]] instead < P>
Your problem
Comments
Post a Comment