This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Suppose you have a datetime stamp in a dataset for the timezone where you are. This dataset includes data for locations in timezones other than the one you're in and you want to convert your datetime stamp to reflect the local timezones of the locatons in your data.
In the attached example, we'll pretend you're in the Eastern Standard Timezone and your datetime stamps are EST. Your data includes the following locations:
San Mateo, CA
Sydney, NSW, Australia
Toronto, Ontario, Canada
We'll convert your EST datetime stamp to the local timezones of these locations. This solution will use latitude / longitude coordinates to determine the local timezones. Your data will need have lat/long coordinates for each of your locations.
The solution will use a Google API to find the UTC time offsets. Depending on the date, this could include an adjustment for daylight savings as well. To read more about the API being used, visit https://developers.google.com/maps/documentation/timezone/intro#Introduction. This site will give you information about which parameters are used to make an API call, and what data is returned. This is informational since Alteryx handles the data call and data engineering.
The Google Maps Time Zone API application (and most API applications in general) require some form of authentication. This means you will need to get an API key. It’s free to get a key, but you are limited to the number of calls you can make per day (I believe it’s currently set at 5K. If you are going to have more than 5K lines of data, let me know; we may be able to come up with something else). Go to https://developers.google.com/maps/documentation/timezone/get-api-key#key and look for this:
Click on get a key. A new browser tab will open that looks like this:
Go ahead and click Continue. You’ll see a message in a black box that say ‘Creating a new project’. A new window looks like this:
You can give your key any name you want, but you will need to enter your IP address. To find your IP address, go to https://www.whatismyip.com/. Look for ‘Your IP Address Is:’ and copy/paste your IP. Click Create. It says it may take up to 5 minutes for settings to take effect.
Once you have your API key, copy and save it somewhere like NotePad. You’ll need to enter your API key in the macro configuration window. Once you enter your key and save the workflow, you shouldn’t have to reenter it again.
Your input data looks like this:
Where the DateTimeStamp is in EST. The goal is change EST to local of time of each location. Attach your input file to the 'UTC to Local Time Converter Example' macro.
Replace 'YOUR_API_KEY' with the API Key you acquired and pasted/saved in NotePad (from above):
The browser results show the results from the conversion:
NOTE: the attached example was developed on Alteryx Designer v10.1.7.1288
The UTC to Local Time Converter Example macro will make the appropriate daylight savings adjustment.