<html><DIV>
<P>does your method take in the consideration for daylight savings time? also this 
relies on user setting his/her computer time correctly. well it all comes down to how 
important this is in your application. for us, we were thinking about doing the same, 
but the ability to determine time in timezone between users was crucial part of the 
app and we didn't want to make any part of the site relying on javascript. so we 
couldn't go this route.<BR>just trying to help.<BR></P></DIV>
<DIV></DIV>
<DIV></DIV>&gt;From: "Marc Funaro" <[EMAIL PROTECTED]>
<DIV></DIV>&gt;Reply-To: [EMAIL PROTECTED] 
<DIV></DIV>&gt;To: Fusebox <[EMAIL PROTECTED]>
<DIV></DIV>&gt;Subject: RE: [OT] Timezone madness 
<DIV></DIV>&gt;Date: Fri, 30 Mar 2001 11:07:50 -0500 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I don't see how this can help if your dll requires a timezone -- which 
is 
<DIV></DIV>&gt;exactly what I am attempting to determine. I am not translating from 
one 
<DIV></DIV>&gt;timezone to many different timezones. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;One last time, in a different set of words: 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;We have ONE constant: The server's local time. We know what time zone 
the 
<DIV></DIV>&gt;server is in. We convert that time zone to UTC using the DateConvert() 
<DIV></DIV>&gt;function. Therefore, we know what time it is, in UTC, when the user 
submits 
<DIV></DIV>&gt;their form. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Along with the form submission, we "secretly" send the time and date on 
the 
<DIV></DIV>&gt;USERS computer, in a hidden field, using javascript. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;We convert that hidden field data to ODBC Date time format. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;We compare that data with the known UTC, to determine the USER'S 
timezone 
<DIV></DIV>&gt;offset, which we then store in the database. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;We store ALL dates and times for all records in UTC format, and we use 
the 
<DIV></DIV>&gt;USER'S timezone offset to display times and dates to them according to 
their 
<DIV></DIV>&gt;timezone. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;The code that does not work as it should, unless you make UTC at least 
one 
<DIV></DIV>&gt;second faster than it is: 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;<CFOUTPUT> 
<DIV></DIV>&gt; <CFSET 12:00:00?) TestUTCNow='CreateODBCDateTime("3/30/2001'>
<DIV></DIV>&gt; <CFSET 4:00:00?) TestUserTime='CreateODBCDateTime("3/30/2001'>
<DIV></DIV>&gt; <CFSET TestUserTime) TestUTCNow, UserTZOffset='DateDiff("h",'>
<DIV></DIV>&gt; User's TimeZoneOffset = #UserTZOffset# <!--- This SHOULD be -8, but is
</DIV>>only -7! Unless, you make UTCNow equal to "3/30/2001 12:00:01" --->
<DIV></DIV>&gt;</CFOUTPUT> 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;The output of the above hard-coded sample SHOULD be "-8", meaning the 
user 
<DIV></DIV>&gt;is in California, 8 hours BEHIND UTC. When displaying dates and times 
out 
<DIV></DIV>&gt;of the database for this user, we will first subtract 8 hours from the 
data. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;However, the above code only spits out -7. This is the problem at hand. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Nobody yet has established a better way to automatically determine the 
<DIV></DIV>&gt;user's time zone other than what I have set forth above. Our way WOULD 
<DIV></DIV>&gt;work, if the calculation block of code, as I provided above, would do 
what 
<DIV></DIV>&gt;it is supposed to. Is this not a bug in CF 4.5? 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Additional, just discovered information -- if we LEAVE OFF the 
"seconds" 
<DIV></DIV>&gt;part of the user's time/date information as submitted in the hidden 
form 
<DIV></DIV>&gt;field, the above code DOES spit out -8. Try it: 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;<CFOUTPUT> 
<DIV></DIV>&gt; <CFSET 12:00:00?) TestUTCNow='CreateODBCDateTime("3/30/2001'>
<DIV></DIV>&gt; <CFSET TestUserTime='CreateODBCDateTime("3/30/2001' 4:00:?)>
<DIV></DIV>&gt; <CFSET TestUserTime) TestUTCNow, UserTZOffset='DateDiff("h",'>
<DIV></DIV>&gt; User's TimeZoneOffset = #UserTZOffset# 
<DIV></DIV>&gt;</CFOUTPUT> 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;With the SECONDS missing, it calculates the correct datediff. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;What gives? 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I appreciate the responses to date -- thank you! 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Marc 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;-----Original Message----- 
<DIV></DIV>&gt;From: wish wish [mailto:[EMAIL PROTECTED]] 
<DIV></DIV>&gt;Sent: Friday, March 30, 2001 10:42 AM 
<DIV></DIV>&gt;To: Fusebox 
<DIV></DIV>&gt;Subject: Re: [OT] Timezone madness 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;
<P>i have a .dll which takes in a timezone and a time, it translates it to 
<DIV></DIV>&gt;the time in the timezone you sepecified. all you need to do is to make 
it a 
<DIV></DIV>&gt;CFX custom tag(i didn't have time to do it).
<P></P>
<DIV></DIV>&gt;
<P>if you want i can give it to you. my only request is to share it once you 
<DIV></DIV>&gt;get to work as a CFX tag. you also can test a little more. email me 
<DIV></DIV>&gt;offlist.
<P></P>
<DIV></DIV>&gt;
<P>thanks</P>
<DIV></DIV>&gt;
<P>alex<BR><BR></P>
<DIV></DIV>
<DIV></DIV>&gt;
<DIV></DIV>
<DIV></DIV>&gt;
<DIV></DIV>&gt;From: "Marc Funaro" <[EMAIL PROTECTED]>
<DIV></DIV>&gt;
<DIV></DIV>&gt;Reply-To: [EMAIL PROTECTED] 
<DIV></DIV>&gt;
<DIV></DIV>&gt;To: Fusebox <[EMAIL PROTECTED]>
<DIV></DIV>&gt;
<DIV></DIV>&gt;Subject: [OT] Timezone madness 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Date: Fri, 30 Mar 2001 07:56:57 -0500 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Greetings all, 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Been fighting with this, can't figure out the answer, and 
<DIV></DIV>&gt;going mad. I am 
<DIV></DIV>&gt;
<DIV></DIV>&gt;storing all times and dates in a database in UTC (GMT) 
<DIV></DIV>&gt;format, to properly 
<DIV></DIV>&gt;
<DIV></DIV>&gt;show users the time according to their time zone, and allow 
<DIV></DIV>&gt;the server to be 
<DIV></DIV>&gt;
<DIV></DIV>&gt;(re)located anywhere in the world without having to change 
<DIV></DIV>&gt;code or data. 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Ignore Daylight Savings Time considerations for this example 
<DIV></DIV>&gt;(though if you 
<DIV></DIV>&gt;
<DIV></DIV>&gt;have any suggestions, I am all ears!) -- I have not had the 
<DIV></DIV>&gt;chance to even 
<DIV></DIV>&gt;
<DIV></DIV>&gt;think about DST yet. 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;1. The user fills out a form. When they submit, a hidden form 
<DIV></DIV>&gt;field is 
<DIV></DIV>&gt;
<DIV></DIV>&gt;populated with the user's current system time and date, using 
<DIV></DIV>&gt;javascript. 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Since Javascript calculates the months from 0 to 11, I add 
<DIV></DIV>&gt;ONE to the month 
<DIV></DIV>&gt;
<DIV></DIV>&gt;at the time I create the timestamp. 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;2. The form submits to a page which converts the current CF 
<DIV></DIV>&gt;Server time to 
<DIV></DIV>&gt;
<DIV></DIV>&gt;an ODBCDateTime in UTC. The User's hidden time field is also 
<DIV></DIV>&gt;converted to 
<DIV></DIV>&gt;
<DIV></DIV>&gt;an ODBCDateTime format. 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;3. The different between the user's timestamp on their 
<DIV></DIV>&gt;machine, and the UTC 
<DIV></DIV>&gt;
<DIV></DIV>&gt;according to the server creates the Time Zone Offset for that 
<DIV></DIV>&gt;user -- their 
<DIV></DIV>&gt;
<DIV></DIV>&gt;actual TIME ZONE. 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;As a real-world example: 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;-- Assume that the Server and the User both use a utility 
<DIV></DIV>&gt;which maintains 
<DIV></DIV>&gt;
<DIV></DIV>&gt;synchronization with time servers on the Internet; therefore 
<DIV></DIV>&gt;the two systems 
<DIV></DIV>&gt;
<DIV></DIV>&gt;are within milliseconds of Atomic Time. 
<DIV></DIV>&gt;
<DIV></DIV>&gt;-- On March 30th, 2001, a user in NY submits a form at 7am 
<DIV></DIV>&gt;EST, on a server 
<DIV></DIV>&gt;
<DIV></DIV>&gt;in California (4am PST). 
<DIV></DIV>&gt;
<DIV></DIV>&gt;-- The software calculates the current UTC time as being 
<DIV></DIV>&gt;12:00:00PM (4am CA 
<DIV></DIV>&gt;
<DIV></DIV>&gt;time is 12 noon GMT/UTC). 
<DIV></DIV>&gt;
<DIV></DIV>&gt;-- The difference between the user's time (3/30/2001 
<DIV></DIV>&gt;4:00:00am) and UTC 
<DIV></DIV>&gt;
<DIV></DIV>&gt;(12:00:00PM) is -8 hours, which is absolutely correct; we 
<DIV></DIV>&gt;know the user is 
<DIV></DIV>&gt;
<DIV></DIV>&gt;in PST because of this difference. 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;NOW!: The code snippet below shows the CF Code that calcuates 
<DIV></DIV>&gt;the 
<DIV></DIV>&gt;
<DIV></DIV>&gt;difference between the user's time and UTC. However, if you 
<DIV></DIV>&gt;run this code, 
<DIV></DIV>&gt;
<DIV></DIV>&gt;you will NOT get a difference of - 8 hours, but instead, -7 
<DIV></DIV>&gt;hours. If you 
<DIV></DIV>&gt;
<DIV></DIV>&gt;increment UTC by at least one second, it then calculates the 
<DIV></DIV>&gt;timezone 
<DIV></DIV>&gt;
<DIV></DIV>&gt;properly; but one cannot assume that the user and the server 
<DIV></DIV>&gt;will always be 
<DIV></DIV>&gt;
<DIV></DIV>&gt;out of synch... although it is most likely a certainty, I do 
<DIV></DIV>&gt;not wish to 
<DIV></DIV>&gt;
<DIV></DIV>&gt;assume anything. 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;I also do not wish to make the user choose their time zone on 
<DIV></DIV>&gt;the form; I 
<DIV></DIV>&gt;
<DIV></DIV>&gt;really wanted this to be automatic. 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Here is the code: 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;<CFOUTPUT> 
<DIV></DIV>&gt;
<DIV></DIV>&gt; <CFSET 12:00:00?) DIV 
<>&gt;TestUTCNow='CreateODBCDateTime("3/30/2001'&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt; <CFSET 4:00:00?) DIV 
<>&gt;TestUserTime='CreateODBCDateTime("3/30/2001'&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt; <CFSET TestUserTime) TestUTCNow, DIV 
<>&gt;UserTZOffset='DateDiff("h",'&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt; User's TimeZoneOffset = #UserTZOffset# <!--- This SHOULD
</DIV>>be -8, but is
</DIV>></DIV>>only -7! Unless, you make UTCNow equal to "3/30/2001 12:00:01" --->
<DIV></DIV>&gt;
<DIV></DIV>&gt;</CFOUTPUT> 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Has anyone solved this problem, or have a different way of 
<DIV></DIV>&gt;putting the 
<DIV></DIV>&gt;
<DIV></DIV>&gt;user's timezone into the database, including DST issues? 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Thanks in advance, 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt;.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
<DIV></DIV>&gt;.. . . 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Marc Funaro, President 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Advantex Technical Consulting Services 
<DIV></DIV>&gt;
<DIV></DIV>&gt;5547 State Highway 12 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Norwich, NY 13815 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Phone: 607-336-6895 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Fax: 801-383-4864 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Internet: http://www.advantex.net 
<DIV></DIV>&gt;
<DIV></DIV>&gt;Email: [EMAIL PROTECTED] &gt;/&gt;<?xml:namespace prefix = mailto 
/><mailto:[EMAIL PROTECTED]> 
<DIV></DIV>&gt;
<DIV></DIV>&gt;.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
<DIV></DIV>&gt;.. . . 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
<DIV></DIV>&gt; 
<DIV></DIV>&gt;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to