how to use nsdateformatter to Venezuela

I’m trying to schedule a date on the calendar, which has a start time and an end time, everything works fine if the time zone is in the U.S., and the date the change does not help and I need it to Venezuela what should I do as I place generica, to serve me anywhere no matter the time zone?

here I leave the code as data and bring me as I make the date format.

  • Display different amount of cells in a row within a UICollectionView
  • Swift: How to get correct UICollectionView height when using snapkit?
  • Xcode Storyboard warning: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration
  • Firebase storage upload works in Simulator but not on iPhone
  • Difference between presentModalViewController and presentViewController?
  • UITableView with infite scrolling and lazy loading
  •  comes the date in the following format: 12/10/2012 05:00 pm
    
      EKEvent* event = [EKEvent eventWithEventStore:eventStore];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
    [dateFormatter setDateFormat:@"dd/MM/yyyy hh:mm:ss a"];
      horafin = [dateFormatter dateFromString:inicio];
    horafin  = [horafin dateByAddingTimeInterval:3600];
    horainicio = [dateFormatter dateFromString:inicio];
    [dateFormatter release];
    
    
    NSString *ti=[[NSString alloc]initWithString:title];
    NSLog(@"");
    event.title =@"juego";
    event.startDate = horainicio;
    event.endDate = horafin;
    event.URL = [NSURL URLWithString:@"http://pagina.com"];
    event.notes = ti;
    event.allDay = NO;
    vc.event = event;
    vc.editViewDelegate = self;
    [self presentViewController:vc animated:YES completion:nil];
    

    The event calendar call me correctly only fails when you change the time zone, as I did not take the date correctly I can do?

    2 Solutions Collect From Internet About “how to use nsdateformatter to Venezuela”

    I use following code to get desired timezone-converted datetime:

    - (NSString *) getUTCDate : (NSString *) inputDate
    {
        NSDateFormatter *utcDateFormatter = [[NSDateFormatter alloc] init];
        [utcDateFormatter setDateFormat:@"dd-MMM-yyyy HH:mm:ss Z"];
        [utcDateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
      //  [utcDateFormatter setTimeZone :[NSTimeZone timeZoneForSecondsFromGMT: 0]];        
        // utc format
        NSDate *dateInUTC = [utcDateFormatter dateFromString: inputDate];        
    
        return dateInUTC;
    }
    

    where dateInUTC is the date in GMT timezone.

    You need to replace your own timezone in call [NSTimeZone timeZoneWithName:@"UTC"] and it should work.

    Simply change one line of code in your code…

    [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
    

    This will set time format in universal which doesnot change with region or day light saving time.