Have you struggled with timezones in Salesforce? Let's say you need to report call peak times in a support center and the user should be able to pick their own local times to filter (or see the time ranges in their own local time rather than GMT).
I once read someone commenting "I would rather fight a swarm of wasps with nunchucks than fight with date/times". I didn't think wasps needed to be carrying nunchucks to be dangerous! π
One solution is in this "Reflect a Userβs Correct Time Zone in a Formula" article - π thanks to Eric Praud π - for the great series "How I Solved This":
π LINK: https://lnkd.in/gVwK2mfa
His solution is to store the user's timezone offset: a flow on the User object populates fields with the timezone offset and Daylight Savings Time (from a custom object), then a formula extracts and converts the CreatedDate hour to the user's value.
Another solution is to run Apex to parse the timezone offset number from the system time formatted as string. π Thanks to Matt Lacey ! π
π LINK: https://lnkd.in/gyPNW8ad
Another Apex alternative is to subtract the GMT current time from the current time as explained in this Stack Exchange answer - π thanks to Marty Chang ! π
π LINK: https://lnkd.in/girSHwCA
And there is this solution which I've found brilliant: it is a single formula that is lengthy but easy to understand. It subtracts the different values of DATEVALUE() and DATETIMEVALUE() functions for each hour to get the timezone offset.
In addition he offers another formula to determine the Daylight Savings Time for US (it can be changed for EU dates).
π Thanks to Jason Samson ! π
π LINK: https://lnkd.in/gr3jiHec



