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

  • Home
  • SEARCH
  • 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 8943549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:48:02+00:00 2026-06-15T11:48:02+00:00

This is my code! But event.startDate return 2012-12-29 18:05:00 +0000 data is a string

  • 0

This is my code! But event.startDate return 2012-12-29 18:05:00 +0000

data is a string = “04-12-2012”

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
 [dateFormat setDateFormat:@"dd-MM-YYYY HH:mm"];
 NSDate *date = [dateFormat dateFromString:[NSString stringWithFormat:@"%@ %@",data,oraInizio]];
 NSDate *date2 = [dateFormat dateFromString:[NSString stringWithFormat:@"%@ %@",data,oraFine]];

event.startDate=date;
event.endDate=date2;

Why 2012-12-29 and not 2012-12-04 ??

This is the complete script

- (IBAction)aggiungiEvento:(id)sender {

    EKEventStore *eventStore = [[EKEventStore alloc] init];

    if([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
     // iOS 6 and later
     [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        if (granted){

            EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
            event.title     = [NSString stringWithFormat:@"%@ al %@",tipoLocale,nomeLocale];

            NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
            [dateFormat setDateFormat:@"dd-MM-YYYY HH:mm"];

            NSLog(@"%@   %@",data,oraInizio);

            NSDate *date = [dateFormat dateFromString:[NSString stringWithFormat:@"%@ %@",data,oraInizio]];
            NSDate *date2 = [dateFormat dateFromString:[NSString stringWithFormat:@"%@ %@",data,oraFine]];


            event.startDate=date;
            event.endDate=date2;

            [event setCalendar:[eventStore defaultCalendarForNewEvents]];
            NSError *err;
            [eventStore saveEvent:event span:EKSpanThisEvent error:&err];

             NSLog(@"%@  %@",event.startDate,data);

        }else
        {
            //----- codes here when user NOT allow your app to access the calendar.
        }
    }];
}
  • 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-15T11:48:03+00:00Added an answer on June 15, 2026 at 11:48 am

    It is because you have used @"YYYY" when you should have used @”yyyy” in the year part of your format.

    Note that even after you fix that, your time may still be wrong if you don’t do something about specifying the time zone.

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

Sidebar

Related Questions

I'm trying to run this code but this error appear: Uncaught TypeError: string is
I am working on this code but even after consulting other threads I am
I wrote this code for zoom in/out . it works but even with one
I am trying to use SpinLock, but even this most basic code in a
Why do I get error in this code?Even if i do not link but
I have write this code but it does work only if I am already
Hey I have this code but it doesn't work because it is expecting a
I tried to use this code but it doesn't work. http://developer.apple.com/library/ios/#samplecode/PageControl/Introduction/Intro.html Ld /Users/waitonza/Library/Developer/Xcode/DerivedData/Dr_Ngoo-aanknxmuodcgjicaigxevljxokeq/Build/Products/Debug-iphonesimulator/Dr Ngoo.app/Dr
Hi guys I was looking at this code but I'm struggling to understand what
I am getting segmentation fault in this code but i cant figure out why.

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.