<html><DIV>
<P>i have a .dll which takes in a timezone and a time, it translates it to the time in 
the timezone you sepecified. all you need to do is to make it a CFX custom tag(i 
didn't have time to do it).</P>
<P>if you want i can give it to you. my only request is to share it once you get to 
work as a CFX tag. you also can test a little more. email me offlist.</P>
<P>thanks</P>
<P>alex<BR><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: [OT] Timezone madness 
<DIV></DIV>&gt;Date: Fri, 30 Mar 2001 07:56:57 -0500 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Greetings all, 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Been fighting with this, can't figure out the answer, and going mad. I 
am 
<DIV></DIV>&gt;storing all times and dates in a database in UTC (GMT) format, to 
properly 
<DIV></DIV>&gt;show users the time according to their time zone, and allow the server 
to be 
<DIV></DIV>&gt;(re)located anywhere in the world without having to change code or 
data. 
<DIV></DIV>&gt;Ignore Daylight Savings Time considerations for this example (though if 
you 
<DIV></DIV>&gt;have any suggestions, I am all ears!) -- I have not had the chance to 
even 
<DIV></DIV>&gt;think about DST yet. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;1. The user fills out a form. When they submit, a hidden form field is 
<DIV></DIV>&gt;populated with the user's current system time and date, using 
javascript. 
<DIV></DIV>&gt;Since Javascript calculates the months from 0 to 11, I add ONE to the 
month 
<DIV></DIV>&gt;at the time I create the timestamp. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;2. The form submits to a page which converts the current CF Server time 
to 
<DIV></DIV>&gt;an ODBCDateTime in UTC. The User's hidden time field is also converted 
to 
<DIV></DIV>&gt;an ODBCDateTime format. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;3. The different between the user's timestamp on their machine, and the 
UTC 
<DIV></DIV>&gt;according to the server creates the Time Zone Offset for that user -- 
their 
<DIV></DIV>&gt;actual TIME ZONE. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;As a real-world example: 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;-- Assume that the Server and the User both use a utility which 
maintains 
<DIV></DIV>&gt;synchronization with time servers on the Internet; therefore the two 
systems 
<DIV></DIV>&gt;are within milliseconds of Atomic Time. 
<DIV></DIV>&gt;-- On March 30th, 2001, a user in NY submits a form at 7am EST, on a 
server 
<DIV></DIV>&gt;in California (4am PST). 
<DIV></DIV>&gt;-- The software calculates the current UTC time as being 12:00:00PM 
(4am CA 
<DIV></DIV>&gt;time is 12 noon GMT/UTC). 
<DIV></DIV>&gt;-- The difference between the user's time (3/30/2001 4:00:00am) and UTC 
<DIV></DIV>&gt;(12:00:00PM) is -8 hours, which is absolutely correct; we know the user 
is 
<DIV></DIV>&gt;in PST because of this difference. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;NOW!: The code snippet below shows the CF Code that calcuates the 
<DIV></DIV>&gt;difference between the user's time and UTC. However, if you run this 
code, 
<DIV></DIV>&gt;you will NOT get a difference of - 8 hours, but instead, -7 hours. If 
you 
<DIV></DIV>&gt;increment UTC by at least one second, it then calculates the timezone 
<DIV></DIV>&gt;properly; but one cannot assume that the user and the server will 
always be 
<DIV></DIV>&gt;out of synch... although it is most likely a certainty, I do not wish 
to 
<DIV></DIV>&gt;assume anything. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I also do not wish to make the user choose their time zone on the form; 
I 
<DIV></DIV>&gt;really wanted this to be automatic. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Here is the code: 
<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;Has anyone solved this problem, or have a different way of putting the 
<DIV></DIV>&gt;user's timezone into the database, including DST issues? 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Thanks in advance, 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
<DIV></DIV>&gt;Marc Funaro, President 
<DIV></DIV>&gt;Advantex Technical Consulting Services 
<DIV></DIV>&gt;5547 State Highway 12 
<DIV></DIV>&gt;Norwich, NY 13815 
<DIV></DIV>&gt;Phone: 607-336-6895 
<DIV></DIV>&gt;Fax: 801-383-4864 
<DIV></DIV>&gt;Internet: http://www.advantex.net 
<DIV></DIV>&gt;Email: [EMAIL PROTECTED] <?xml:namespace prefix = mailto 
/><mailto:[EMAIL PROTECTED]>
<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