Kango
Kango

Reputation: 847

How to get time zone for city

I am new with php.

How can i get available timezones for users if i know user city or ip address or region.

For example: if user is from Florida, USA it has time zone
1. Eastern Time Zone
2. Central Time zone

Any possible way to get this using PHP or jquery plugin.

Upvotes: 3

Views: 6016

Answers (3)

Deenadhayalan Manoharan
Deenadhayalan Manoharan

Reputation: 5444

Try this..

<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js">
</script>
<script type="text/javascript">
  $(document).ready(function(){
    var tz = jstz.determine(); 
    var timezone = tz.name();
    alert(timezone);    
  });
</script>

Upvotes: 2

Dhruv Ramani
Dhruv Ramani

Reputation: 2643

Google has a neat API to get time-zones based on the location. Here's the link to it: https://developers.google.com/maps/documentation/timezone/

Happy Coding!

Upvotes: 0

Sonali Gupta
Sonali Gupta

Reputation: 308

I think you should try this. The function will return the time zone corresponding to a country and region code combo. : http://php.net/manual/en/function.geoip-time-zone-by-country-and-region.php

Upvotes: 1

Related Questions