<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Auto detect a time zone with JavaScript</title>
	<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/</link>
	<description></description>
	<pubDate>Sun, 07 Sep 2008 18:46:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>

	<item>
		<title>By: Justin</title>
		<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-233</link>
		<author>Justin</author>
		<pubDate>Wed, 16 Jul 2008 04:27:48 +0000</pubDate>
		<guid>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-233</guid>
		<description>Josh,

Great script. Is there anyway to modify the script to only use US timezones? I have the following timezones in my database, and I want to match the client to one of these timezones. The exceptions, Indiana and Arizona do not have their own timezone in my database, they simply fall into a standard zone. Thanks.

AKST  	ALASKAN STANDARD TIME  	-9
AST 	ATLANTIC STANDARD TIME 	-4
CST 	CENTRAL STANDARD TIME 	-6
EST 	EASTERN STANDARD TIME 	-5
HST 	HAWAII-ALEUTIAN STANDARD TIME 	-10
MST 	MOUNTAIN STANDARD TIME 	-7
PST 	PACIFIC STANDARD TIME 	-8
AKDT 	ALASKAN DAYLIGHT SAVING TIME 	-8
ADT 	ATLANTIC DAYLIGHT SAVING TIME 	-3
CDT 	CENTRAL DAYLIGHT SAVING TIME 	-5
EDT 	EASTERN DAYLIGHT SAVING TIME 	-4
PDT 	PACIFIC DAYLIGHT SAVING TIME 	-7
MDT 	MOUNTAIN DAYLIGHT SAVING TIME 	-6</description>
		<content:encoded><![CDATA[<p>Josh,</p>
<p>Great script. Is there anyway to modify the script to only use US timezones? I have the following timezones in my database, and I want to match the client to one of these timezones. The exceptions, Indiana and Arizona do not have their own timezone in my database, they simply fall into a standard zone. Thanks.</p>
<p>AKST  	ALASKAN STANDARD TIME  	-9<br />
AST 	ATLANTIC STANDARD TIME 	-4<br />
CST 	CENTRAL STANDARD TIME 	-6<br />
EST 	EASTERN STANDARD TIME 	-5<br />
HST 	HAWAII-ALEUTIAN STANDARD TIME 	-10<br />
MST 	MOUNTAIN STANDARD TIME 	-7<br />
PST 	PACIFIC STANDARD TIME 	-8<br />
AKDT 	ALASKAN DAYLIGHT SAVING TIME 	-8<br />
ADT 	ATLANTIC DAYLIGHT SAVING TIME 	-3<br />
CDT 	CENTRAL DAYLIGHT SAVING TIME 	-5<br />
EDT 	EASTERN DAYLIGHT SAVING TIME 	-4<br />
PDT 	PACIFIC DAYLIGHT SAVING TIME 	-7<br />
MDT 	MOUNTAIN DAYLIGHT SAVING TIME 	-6</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: scornflakes</title>
		<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-230</link>
		<author>scornflakes</author>
		<pubDate>Sat, 14 Jun 2008 13:09:08 +0000</pubDate>
		<guid>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-230</guid>
		<description>I'm using the time zones from http://www.php.net/manual/en/function.timezone-abbreviations-list.php so I have a way of mapping the offset and DST to the zone (though I will not get the correct value for multiple time zones with the same offset and DST).
Currently, I won't bother to extend your JS so that it determines which time zone to select via Ajax, but if I ever do, I'll post back. If someone else does, I'm watching these comments and I'd like to see your results!
Ruben</description>
		<content:encoded><![CDATA[<p>I&#8217;m using the time zones from <a href="http://www.php.net/manual/en/function.timezone-abbreviations-list.php" rel="nofollow" onclick="javascript:urchinTracker ('/outbound/comment/www.php.net');">http://www.php.net/manual/en/function.timezone-abbreviations-list.php</a> so I have a way of mapping the offset and DST to the zone (though I will not get the correct value for multiple time zones with the same offset and DST).<br />
Currently, I won&#8217;t bother to extend your JS so that it determines which time zone to select via Ajax, but if I ever do, I&#8217;ll post back. If someone else does, I&#8217;m watching these comments and I&#8217;d like to see your results!<br />
Ruben</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Fraser</title>
		<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-229</link>
		<author>Josh Fraser</author>
		<pubDate>Mon, 02 Jun 2008 16:37:12 +0000</pubDate>
		<guid>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-229</guid>
		<description>Mike,

No, that's not a bug.  It's just an if-statement without braces.  

You do bring up a good point that people should understand.  This script works under the presumption that you are only wanting to store the GMT offset and the DST boolean.

This script condenses multiple timezones in order to have only 1 primary key on GMT offset/DST.  While this usually works in practice, you do loose some accuracy in knowing an exact TZ.</description>
		<content:encoded><![CDATA[<p>Mike,</p>
<p>No, that&#8217;s not a bug.  It&#8217;s just an if-statement without braces.  </p>
<p>You do bring up a good point that people should understand.  This script works under the presumption that you are only wanting to store the GMT offset and the DST boolean.</p>
<p>This script condenses multiple timezones in order to have only 1 primary key on GMT offset/DST.  While this usually works in practice, you do loose some accuracy in knowing an exact TZ.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-228</link>
		<author>Mike</author>
		<pubDate>Sun, 01 Jun 2008 22:47:14 +0000</pubDate>
		<guid>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-228</guid>
		<description>looks like my above entries...screwed up other stuff...
dealing with the DST calcs...backed them out.
Why tie Hemisphere to whether the system is currently on DST?
and if not curently on DST my -6 CST-US would report as -6 CST-Central Am ???
===
my system (WIN-XP) has 5: (GMT -6:00 CST) entries
Central America
Central Time (US &#38; Canada)
Central Time Guadalajara, Mexico city, Monterrey - New
Central Time Guadalajara, Mexico city, Monterrey - Old
Central Time Saskatchewan
===
If change my system to any - all go to CST US
===
also have bunches of other TZ's in list, that are not in the OPTION list.
So this has not been updated, since all of the TZ changes from MS in 2007?</description>
		<content:encoded><![CDATA[<p>looks like my above entries&#8230;screwed up other stuff&#8230;<br />
dealing with the DST calcs&#8230;backed them out.<br />
Why tie Hemisphere to whether the system is currently on DST?<br />
and if not curently on DST my -6 CST-US would report as -6 CST-Central Am ???<br />
===<br />
my system (WIN-XP) has 5: (GMT -6:00 CST) entries<br />
Central America<br />
Central Time (US &amp; Canada)<br />
Central Time Guadalajara, Mexico city, Monterrey - New<br />
Central Time Guadalajara, Mexico city, Monterrey - Old<br />
Central Time Saskatchewan<br />
===<br />
If change my system to any - all go to CST US<br />
===<br />
also have bunches of other TZ&#8217;s in list, that are not in the OPTION list.<br />
So this has not been updated, since all of the TZ changes from MS in 2007?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-227</link>
		<author>Mike</author>
		<pubDate>Sun, 01 Jun 2008 20:38:26 +0000</pubDate>
		<guid>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-227</guid>
		<description>also needed to set DST with an "else"... 
==
     if (hemisphere &#62;= 0) {
       std_time_offset = daylight_time_offset;
       dst = "1";      // daylight savings time is observed
       }
     else {
       dst = "0";      // daylight savings time is not observed
     }
   }

   var i;
===</description>
		<content:encoded><![CDATA[<p>also needed to set DST with an &#8220;else&#8221;&#8230;<br />
==<br />
     if (hemisphere &gt;= 0) {<br />
       std_time_offset = daylight_time_offset;<br />
       dst = &#8220;1&#8243;;      // daylight savings time is observed<br />
       }<br />
     else {<br />
       dst = &#8220;0&#8243;;      // daylight savings time is not observed<br />
     }<br />
   }</p>
<p>   var i;<br />
===</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-226</link>
		<author>Mike</author>
		<pubDate>Sun, 01 Jun 2008 20:18:23 +0000</pubDate>
		<guid>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-226</guid>
		<description>downloaded the index.html &#38; detect_timezone.js today (06/01/2008) 
==

bug?...
In the calculate_time_zone function...
"if (hemisphere &#62;= 0) " ....missing the IF's starting {
and then also added } before the function end to properly end the prior ELSE</description>
		<content:encoded><![CDATA[<p>downloaded the index.html &amp; detect_timezone.js today (06/01/2008)<br />
==</p>
<p>bug?&#8230;<br />
In the calculate_time_zone function&#8230;<br />
&#8220;if (hemisphere &gt;= 0) &#8221; &#8230;.missing the IF&#8217;s starting {<br />
and then also added } before the function end to properly end the prior ELSE</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tas</title>
		<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-224</link>
		<author>Tas</author>
		<pubDate>Mon, 12 May 2008 22:17:04 +0000</pubDate>
		<guid>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-224</guid>
		<description>Arizona time: (Arizona Time)
http://www.google.ca/search?hl=en&#38;q=arizona+time&#38;meta=

Vancouver time: (PDT)
http://www.google.ca/search?hl=en&#38;q=vancouver+time&#38;meta=

Vancouver and Phoenix are the same time. at the time I wrote this entry, it was 3:12pm. this will however change when we switch back to PST. 

I don't think it's up to the browser, it's up to the windows system to switch the DST settings, and the browser will pick up from the OS.

However I understand you will have issues if you are trying to get the TimeZone using getTimezoneOffset(), because as the function will only gives you the offset of where the computer is currently located compared to GMT as documentation states. You would however get different results in another time of the year if you are trying to guess the timezoe of the computer, but the function is not intended for that.</description>
		<content:encoded><![CDATA[<p>Arizona time: (Arizona Time)<br />
<a href="http://www.google.ca/search?hl=en&amp;q=arizona+time&amp;meta=" rel="nofollow" onclick="javascript:urchinTracker ('/outbound/comment/www.google.ca');">http://www.google.ca/search?hl=en&amp;q=arizona+time&amp;meta=</a></p>
<p>Vancouver time: (PDT)<br />
<a href="http://www.google.ca/search?hl=en&amp;q=vancouver+time&amp;meta=" rel="nofollow" onclick="javascript:urchinTracker ('/outbound/comment/www.google.ca');">http://www.google.ca/search?hl=en&amp;q=vancouver+time&amp;meta=</a></p>
<p>Vancouver and Phoenix are the same time. at the time I wrote this entry, it was 3:12pm. this will however change when we switch back to PST. </p>
<p>I don&#8217;t think it&#8217;s up to the browser, it&#8217;s up to the windows system to switch the DST settings, and the browser will pick up from the OS.</p>
<p>However I understand you will have issues if you are trying to get the TimeZone using getTimezoneOffset(), because as the function will only gives you the offset of where the computer is currently located compared to GMT as documentation states. You would however get different results in another time of the year if you are trying to guess the timezoe of the computer, but the function is not intended for that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Fraser</title>
		<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-223</link>
		<author>Josh Fraser</author>
		<pubDate>Mon, 12 May 2008 21:09:00 +0000</pubDate>
		<guid>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-223</guid>
		<description>Tas, 
So PDT and Arizona are both 420 minutes (7hrs) from GMT?  I think we both know that's not true.  The reason you got the same value for 2 very different timezones is that the most browsers (older versions of IE don't) go ahead and factor DST into the offset.  This also means that you get different results depending on the time of year.  My goal with writing this function was to make something that works in all browsers and returns consistent results regardless of the time of year.  It also separates timezone offset and DST into separate variables -- something that isn't possible using only  gettimezoneoffset().</description>
		<content:encoded><![CDATA[<p>Tas,<br />
So PDT and Arizona are both 420 minutes (7hrs) from GMT?  I think we both know that&#8217;s not true.  The reason you got the same value for 2 very different timezones is that the most browsers (older versions of IE don&#8217;t) go ahead and factor DST into the offset.  This also means that you get different results depending on the time of year.  My goal with writing this function was to make something that works in all browsers and returns consistent results regardless of the time of year.  It also separates timezone offset and DST into separate variables &#8212; something that isn&#8217;t possible using only  gettimezoneoffset().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tas</title>
		<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-222</link>
		<author>Tas</author>
		<pubDate>Mon, 12 May 2008 20:41:56 +0000</pubDate>
		<guid>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-222</guid>
		<description>Did change the clock to Arizona time and it's still consistent results. 420 offsets in both IE 7 and FIREFOX Mozilla 5.0. win xp.

considering vancouver, bc is on PDT, it should match the time in Arizona. that's why I get 420 offset each way which is correct. 

are you suggesting Javascript has a bug that is not documented?</description>
		<content:encoded><![CDATA[<p>Did change the clock to Arizona time and it&#8217;s still consistent results. 420 offsets in both IE 7 and FIREFOX Mozilla 5.0. win xp.</p>
<p>considering vancouver, bc is on PDT, it should match the time in Arizona. that&#8217;s why I get 420 offset each way which is correct. </p>
<p>are you suggesting Javascript has a bug that is not documented?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Fraser</title>
		<link>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-221</link>
		<author>Josh Fraser</author>
		<pubDate>Mon, 12 May 2008 15:48:10 +0000</pubDate>
		<guid>http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/#comment-221</guid>
		<description>Tas, change the clock on your computer to Arizona time and see if you still feel that way.  :)</description>
		<content:encoded><![CDATA[<p>Tas, change the clock on your computer to Arizona time and see if you still feel that way.  <img src='http://onlineaspect.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>
