zaiff
zaiff

Reputation: 1009

How to get the current time in any location

I have to upload an image and with that i have to send the date and time when the image is uploaded, I am getting the latitude and longitude of the device from which it is uploaded, now i want to get the time and date of that location at that point of time when the image is uploaded. I do not want to take the date and time from device, Is it possible to get the date and time with the help of latitude and longitude of that place.

Upvotes: 1

Views: 1105

Answers (1)

Rajdeep Dua
Rajdeep Dua

Reputation: 11230

You can get the time zone and the current local time for a lat long from webservice by GeoNames http://www.geonames.org/export/web-services.html#timezone.

Demo link http://api.geonames.org/timezoneJSON?lat=47.01&lng=10.2&username=demo

Output Format

{"time":"2011-12-28 08:03",
 "countryName":"Austria",
 "sunset":"2011-12-28 16:36",
 "rawOffset":1,
 "dstOffset":2,
 "countryCode":"AT",
 "gmtOffset":1,
 "lng":10.2,
 "sunrise":"2011-12-28 08:04",
 "timezoneId":"Europe/Vienna",
 "lat":47.01
}

Register for a username here http://www.geonames.org/login

Upvotes: 1

Related Questions