I am mailing out reminders to potential customers and the time is getting converted to our servers timezone EST (I think it is currently using EDT though as appropriate). I need to store the timezone for the potential customer and translate the time into their current timezone.
I can store the offset but I am worried about daylight savings time. I can always store a non-DST offset but that causes issues when the signup appointment is scheduled before DST but occurs after DST.
Ideally I would like to store a timezone and have salesforce translate the datetime to that timezone accounting for DST if necessary. How can I do this?
If the option selected includes Daylight Time, then yes, Salesforce will automatically update the time to reflect Daylight Savings Time. If Standard Time is selected, then the time will always remain according to Standard Time and will not adjust with Daylight Savings.
Enter Personal Information in the Quick Find box, then select Personal Information. Then click Edit. Click the Time Zone dropdown list for a list of supported time zones.
In Salesforce, every time you instantiate and insert a DateTime object, it gets saved in the database in GMT Time Zone and it is translated to the user's time zone when reading it.
Salesforce won't convert the UTC value stored in the DB to an arbitrary timezone. It will only convert to the timezone of the in-context user. You could try changing locales of the active user every time you make an API call, but that would be expensive.
Like you said, you need to store the timezone, then use the datetime library and convert from the timezone of your salesforce user (it's probably easier to have a user who is in UTC, but not necessary) to the timezone of your customer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With