14
Views
6
Comments
Solved
GetTimeZone based on state name
Question
Application Type
Reactive

Hi

i have StateName and CityName like (Georgia and Augusta )Based on that Cityname and Statename i need timezone of the state.i have tried to use TimeZone component but it was asking for Google api key and that is not free i think.correct me if i am wrong.i want to pass City and State Name and Based on that i need time zone of the state and city.if any component is there you can suggest me.

mvp_badge
MVP
Rank: #2
Solution

I'm pretty sure that if you google around a bit you can find a way to do that with the Google Maps API. That is, fetch the lattitude and longitude.

EDIT: like this.

mvp_badge
MVP
Rank: #2

Hi Arkyadeep,

For development purposes, you can get a free Google API key, like you also need for Google Maps. I think for production you need to pay, but it's not a hefty fee.

Hi

i have only state name and city name,with help of that i have o fetch Timezone Name.In Google time zone api i have to pass lat and long.there is no provision to send state name and city name to get the Timezone Name.

mvp_badge
MVP
Rank: #2
Solution

I'm pretty sure that if you google around a bit you can find a way to do that with the Google Maps API. That is, fetch the lattitude and longitude.

EDIT: like this.

Rank: #84

Hi,
You can use 2 respective API :

1- Get the Location for City from GoogleAPI :
http://maps.googleapis.com/maps/api/geocode/json?address=San%20Francisco,+CA&sensor=false

2- Pass the retrieved location to TimeZone API

https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510×tamp=1331161200&key=YOUR_API_KEY

You can generate the timestamp manually, for instance in JS:

var targetDate = new Date()
var timestamp = targetDate.getTime()/1000 + targetDate.getTimezoneOffset() * 60 


Hope it helps,
Assif

Thanks for reply.its already resolved

mvp_badge
MVP
Rank: #2

Can you please tell us how? And in case someone gave you a hint in the right direction, please mark their answer as Solution, thanks.