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

Timezone problem with DateTime


We are accessing Salesforce API in .NET

One of the object we are saving from the SF API has a DateTime field. It seems that due to timezone differences between the SF User ( GMT + 11 ) and the host server of .NET application ( GMT ) is causing wrong DateTime being saved in the SF.

Any way to force saving DateTimes as entered wihtout timezone information / adjustment?

Arshad ShaikArshad Shaik
Exactly the same requirement we had few months before.

SF stores the date time in GMT/UTC timezone.
It depends on the user settings which user has set, which decides the timezone to be displayed. Change your user settings to GMT+11 and you can see the exact value which you are passing to .NET

SF User setting already has GMT + 11 timezone 

In Apex:

SomeObject1.DateTime__c = '13/10/2014 14:41:20'; //maybe wrong syntax but understandable


SomeObject2.DateTime__c = new DateTime(13,10,2014,14,41,20); // maybe wrong syntax but understandable

Why does the SomeObject2.DateTime__c is shown with 11 hours ahead in the Salesforce where as SomeObject1.DateTime__c is shown exactly how it was saved from Apex ?

This may work in your case,

TimeZone tz = UserInfo.getTimeZone();

Datetime valueToInsert = Datetime from ,Net - tz.getOffset(Datetime from ,Net);

Finally use 'valueToInsert' too populate in fileld.