Ashu Ashu - 1 year ago 86
PHP Question

how to detect users timezone

i need to know what time zone is currently my users is in based on their Ip or http header.

This is very urgent to me. I got many answer regarding this issue, but i could not understood those answer.
Some said use

-new Date().getTimezoneOffset()/60;
(from here) .But what does it mean ?

I have a
in the root of my (index.php)page. so for this i have to get the timezone dynamically and set it in place of

Please help me in simple way to accomplish this issue.

-Thanks in advance

Answer Source

Thank you Ashutosh for bringing up this discussion and Thanks a million to Matt Johnson for sharing your knowledge with us on time zone.

To summarize Matt Johnson's answer in terms of code:

<script type="text/javascript" src="//">
<script type="text/javascript" src="//">
<script type="text/javascript">
    var tz = jstz.determine(); // Determines the time zone of the browser client
    var timezone =; //'Asia/Kolhata' for Indian Time.
    $.post("url-to-function-that-handles-time-zone", {tz: timezone}, function(data) {
       //Preocess the timezone in the controller function and get
       //the confirmation value here. On success, refresh the page.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download