I have a web application (Rails 4) using Google maps. When a user clicks on a point on the map, the Google map API returns the latitude and longitude. Now, I want to get the current time at that latitude and longitude as well and I'm not sure which route to take to do this. I'd appreciate your advice:
- Use Google Timezone API: the problem here is that Google requires me sending a timestamp. My understanding is that timestamp is the current UTC time that I send from the server to the client and then client's computer sends this timestamp to Google server. Now suppose the user is on the website from 11:55pm to 12:05am. At 12:05am, the user is still having 11:55pm as timestamp (1 day difference) unless I refresh it. Getting current time shouldn't be this complicated and requiring me refreshing and so on.
- Use TimeZone gem: The way I can think of implementing this is that when user clicks on the map, the client sends an Ajax call to my server and then my server sends a request to geonames.org and then the current times is sent to the client. Here there are two server hoppings and I expect delay.
Any easier/faster solution? I'm open to using any other API, gem, etc.