I know there a lot of answers on the web about this issue. I don't know why or what I do wrong, I cant achieve my need.
I'm getting a dateTime from a web service (Guest user) in this format :
05/10/2020 01:05 - MM\DD\YYYY HH:MM
I want to save it in salesforce in a DateTime field exactly as its received - 05/10/2020 01:05:00.
But when I save it, The GMT has come to action and add me 3 hours extra.
I just want to remove the GMT option - I want to receive the date and time as it is.
I tried :
Datetime StartDT = Datetime.newInstance(year,month,day,hour,min,sec); string modStartDT = StartDT.format('yyyy-MM-dd\'T\'HH:mm:ss','GMT');
String stringDate = dateTimeAsString.substring(6,10) + '-' + dateTimeAsString.substring(0,2) + '-' + dateTimeAsString.substring(3,5) + ' ' + dateTimeAsString.substring(11,19); DateTime dt = datetime.valueOf(stringDate);
I tried to add my user GMT in the TimeZone Object.
But what I do not understand - is that guest Users have the GMT Time zone anyway.
Why is it adding the extra hour anyway?
every help will be much appreciated.