Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8411453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:25:35+00:00 2026-06-10T00:25:35+00:00

i am trying to add the event to iPhone default calendar and the code

  • 0

i am trying to add the event to iPhone default calendar and the code is as follows

NSMutableString *startDateString = [NSMutableString stringWithString:@”11/20/2012 10:00 AM”];

NSMutableString *endtDateString = [NSMutableString stringWithString:@”11/20/2012 5:00 PM”];

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// this is imporant - we set our input date format to match our input string
// if format doesn't match you'll get nil from your string, so be careful
[dateFormatter setDateFormat:@"MM-dd-yyyy HH:mm a"];


NSDate * startDate = [[NSDate alloc]init];
startDate = [dateFormatter dateFromString:startDateString];

NSDate *endDate = [[NSDate alloc]init];
endDate = [dateFormatter dateFromString:endtDateString];


EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
event.title     = @"TEST";
event.startDate = startDate;
event.endDate   = endDate;
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];


[startDate release];
[endDate release];


if(!err)
{

    UIAlertView *alertview=[[UIAlertView alloc]initWithTitle:@"TEST" message:@"Event Added successfully " delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

    [alertview show];
    [alertview release];

}


NSLog(@"error is %@",err);

}

the event is successfully adding but the problem is its not adding to event start date its just adding to jan 1st 2001 date all the events are adding to the same date only .

can any one please help me where i am getting wrong & i am using the iPhone 4s & iPhone 3gs with 5.1.1 version.

Thanks in advance .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:25:37+00:00Added an answer on June 10, 2026 at 12:25 am

    Set DateFormat to dateFormatter like this:

    [dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    

    Note: yourdateString should be according to dateFormatter

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add calendar event using the below code in my android
I'm trying to add a google calendar gadget along with an event. However, whenever
I'm trying to add an event to Google Calendar from within a test console
I'm trying to add an event to a Google calendar by accepting the event
Hi I am trying to add event to android calendar. I am new to
I'm trying to add an event to a Google Calendar using the Google API
i am trying to add a recurring event to a google calendar in ICS.
I'm trying to add an event listener to each icon on the map when
I am trying to add click event to one of the widgets that use
I am trying to add MouseMotion event to the label and move it based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.