Timezone is very important in some business use case specially for calling to customer, doctors or patients for different needs. Call center agents or user should call these customers on their preferred time and their timezone.
By default we can not get timezone based on zip code of customer. We can get these information using API like Smarty Street and zipcodeapi. In this post, I am using zipcodeapi to get Timezone information. We have to create apex class to call this API and we are showing that in LWC component. Based on your requirement, you can use use this information.
1. Apex to Time Zone from Zip Code in Salesforce
We have to call REST API of https://www.zipcodeapi.com/ to get timezone from given zip code. We can use named credential to store API url or we can add API url in remote site setting. We have added API url in remote site setting.
You can get API key from https://www.zipcodeapi.com/API.
This will give lot of detail of provided zip code like city, state, area code, time zone and longitude.
2. LWC to show Time Zone information
We can show timezone and other information on LWC component. We have shown timezone and UTC offset detail. We can also use other information returned from API.