1

In my project I am storing a date and time in custom field using SOAP API. Will Salesforce automatically adjust time based on daylight savings time.

For example if I am storing 2012-11-15 T09:00-08:00, in saleforce DB it is stored as 2012-11-15 T17:00. When displaying back on Case/Contact pages it is displayed as 9AM 2012-11-15. This is working as expected.

Do I have to change GMT offset(-8,-7) accordingly for DST or Salesforce will handle it?

If I have to change, how can I get the GMT offset from Salesforce using SOAP API?

Any help is highly appreciated.

I am using SFDC service cloud.

1

These are the points which will help you understand datetime in salesforce:

  1. Salesforce DB always save datetime in UTC
  2. SOAP api call return all date and datetime in UTC format.
  3. You can convert your datetime to users timezone before making callout to salesofrce.

Let me know if you need some more information and please add some more information like which platform you are using for soap api.

Thanks

| improve this answer | |
  • 1
    Thanks SFDCGOD, Yes I am converting, that is adding offset value before inserting into SFDC, but the offset value value is dependent on DST. So how can make offset dynamic or how can I get organization timezone using SOAP or APEX – java_dev Dec 28 '15 at 12:57
  • 1
    @user2151491, the org doesn't have a TZ; running users have timezones based on the value of their User.TimeZoneSidKey – cropredy Dec 28 '15 at 18:19
  • Organisation have time zones, check setup>quick find>company info – java_dev Dec 29 '15 at 9:08
0

You can use Timezone class for getting the Offset dynamically based on TimeZoneSidKey .

Timezone objTimeZone = Timezone.getTimeZone(TimeZoneSidKey);
Decimal decOffSet = objTimeZone.getOffset(DateTime.now()) / (60 * 60);
decOffSet = decOffSet / 1000;
decOffSet = decOffSet.setScale(2);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.