2

I'm interested in getting the timezone of my users. I already have their city, state, zip, lat & lng and I would like to get their timezone. I've one service that does this conversion ( http://api.geonames.org/timezone?lat=47.01&lng=10.2&username=demo) , however i was wondering if there was a better solution, or if someone has wrapped up this functionality into a decent gem.

Schneems
  • 14,918
  • 9
  • 57
  • 84

2 Answers2

4

See this:

http://rubygems.org/gems/timezone

Should be a matter of:

gem install timezone

And then reading through the documentation to hook up your app to it.

Good luck!

DemitryT
  • 391
  • 4
  • 17
  • As a follow up, nowadays the approach is add this gem to your Gemfile (gem 'timezone') and run "bundle install". Enjoy! – DemitryT Feb 25 '13 at 18:53
1

There is a gem which use google timezone service

https://github.com/sck-v/google_timezone

result = GoogleTimezone.fetch(50.1196004, 8.679918299999999)
result.time_zone_id # gives you 'Europe/Berlin'