Q:

How to set time zone according to location?

I have developed a website for which I want to set time according to location. I mean if my site is opened in India then time zone should be automatically set Asia/Calcutta as so on according to location.
Thanks in advance !!!

A:

You can pass timezone from your page with JavaScript:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js"></script>
<script>
    $(document).ready(function(){
        var tz = jstz.determine(); 
        var tzname = tz.name(); 
        $.post("timezone.php", {timezone: tzname});
    });        
</script>

And then process it in PHP script timezone.php.

