function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
victor92victor92 

date format problem

final=[datepicker date];
    NSLog(inicio.description);
    NSLog(final.description);
    NSDateFormatter *formatter;
    formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.000'Z'"];
    NSString *inicioformat=[formatter stringFromDate:inicio];
    NSString *finalformat=[formatter stringFromDate:final];
    if([self.inicio.description isEqualToString:self.final.description]){
        UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Falla en las fechas"
                                                          message:@"La fecha y tiempo inicial no pueden ser el mismo que la fecha e inicio final"
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles:nil];
    }
    else {
    NSArray *keys2=[[NSArray alloc]initWithObjects:@"WhatId",@"StartDateTime",@"EndDateTime",@"Description", nil];
    //NSArray *objs2=[[NSArray alloc]initWithObjects:whoid,inicio.description,final.description, descripcion.text,nil];
    NSArray *objs2=[[NSArray alloc]initWithObjects:whoid,inicioformat,finalformat, descripcion.text,nil];
        NSString *objectType = @"Event";
    NSDictionary *fields=[[NSDictionary alloc] initWithObjects:objs2 forKeys:keys2];
    SFRestRequest *request = [[SFRestAPI sharedInstance] requestForCreateWithObjectType:objectType fields:fields];
    [[SFRestAPI sharedInstance] send:request delegate:self];
    }

 

My problem is that when i check the event in the cloud, the app publish the even with early five hours of difference, the modification hour and date is correct, so its obvious that the cloud have the correct data, i expect someone could help me.

Best Answer chosen by Admin (Salesforce Developers) 
cirrocirro

To have the platform automatically use the correct zone offset from UTC for your User, use the following format:

    [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];

 

All Answers

cirrocirro

To have the platform automatically use the correct zone offset from UTC for your User, use the following format:

    [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];

 

This was selected as the best answer
SoleesSolees

And which one is the other way around? To read correctly UTC formats from the Cloud and converted to local date?