# Using Time, Timezones and Location in Go

DevFeed: [Using Time, Timezones and Location in Go](<https://devfeed.tech/articles/using-time-timezones-and-location-in-go-22069.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2013/08/using-time-timezones-and-location-in-go.html>)

Published: 2013-08-08T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [API](<https://devfeed.tech/topics/api.md>), [XML](<https://devfeed.tech/topics/xml.md>), [DateTime](<https://devfeed.tech/topics/datetime.md>), [Google](<https://devfeed.tech/topics/google.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [ardan-labs](<https://devfeed.tech/tags/ardan-labs.md>), [blog](<https://devfeed.tech/tags/blog.md>), [code](<https://devfeed.tech/tags/code.md>), [data](<https://devfeed.tech/tags/data.md>), [developers](<https://devfeed.tech/tags/developers.md>), [documentation](<https://devfeed.tech/tags/documentation.md>), [go](<https://devfeed.tech/tags/go.md>), [go-programming](<https://devfeed.tech/tags/go-programming.md>), [golang](<https://devfeed.tech/tags/golang.md>), [google](<https://devfeed.tech/tags/google.md>), [http](<https://devfeed.tech/tags/http.md>), [json](<https://devfeed.tech/tags/json.md>), [maps](<https://devfeed.tech/tags/maps.md>), [programming](<https://devfeed.tech/tags/programming.md>), [services](<https://devfeed.tech/tags/services.md>), [web-services](<https://devfeed.tech/tags/web-services.md>)

## AI overview

This tutorial explains how to resolve local tide-station times to UTC in Go. It compares Google's Timezone API and GeoNames's timezone API, including their request requirements, response data, and stated usage considerations, then begins implementing a Google API call in Go.

## Source excerpt

I ran into a problem today. I was building code to consume NOAA's tide station XML document and quickly realized I was in trouble. Here is a small piece of that XML document: <timezone>LST/LDT</timezone> <item> <date>2013/01/01</date> <day>Tue</day> <time>02:06 AM</time> <predictions_in_ft>19.7</predictions_in_ft> <predictions_in_cm>600</predictions_in_cm> <highlow>H</highlow> </item> If you notice the timezone tag, it states the time is in Local Standard Time / Local Daylight Time. This is a real problem because I need to store this data in UTC. Without a proper timezone I am lost. After scratching my head for a bit my business partner showed me two API's that take a latitude and longitude position and return timezone information. Luckily for me I have a latitude and longitude position for each tide station. If you open this web page you can read the documentation for Google's Timezone API: External resource on developers.google.com: https://developers.google.com/maps/documentation/timezone/ The API is fairly simple. It requires a location, timestamps and a flag to identify if the requesting application is using a sensor, like a GPS device, to determine the location. Here is a sample call to the Google API and response: https://maps.googleapis.com/maps/api/timezone/json?location=38.85682,-92.991714&sensor=false&timestamp=1331766000 { "dstOffset" : 3600.0, "rawOffset" : -21600.0, "status" : "OK", "timeZoneId" : "America/Chicago", "timeZoneName" : "Central Daylight Time" } There is a limit of 2,500 calls a day. For my initial load of the tide stations, I knew I was going to hit that limit and I didn't want to wait several days to load all the data. So my business partner found the timezone API from GeoNames. If you open this web page you can read the documentation for GeoNames's Timezone API: [http://www.geonames.org/export/web-services.html#timezone](/broken-link) The API requires a free account which is real quick to setup. Once you activate your account you need t