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