I don't see how this can help if your dll requires a timezone -- which is
exactly what I am attempting to determine. I am not translating from one
timezone to many different timezones.
One last time, in a different set of words:
We have ONE constant: The server's local time. We know what time zone the
server is in. We convert that time zone to UTC using the DateConvert()
function. Therefore, we know what time it is, in UTC, when the user submits
their form.
Along with the form submission, we "secretly" send the time and date on the
USERS computer, in a hidden field, using javascript.
We convert that hidden field data to ODBC Date time format.
We compare that data with the known UTC, to determine the USER'S timezone
offset, which we then store in the database.
We store ALL dates and times for all records in UTC format, and we use the
USER'S timezone offset to display times and dates to them according to their
timezone.
The code that does not work as it should, unless you make UTC at least one
second faster than it is:
<CFOUTPUT>
<CFSET TestUTCNow = CreateODBCDateTime("3/30/2001 12:00:00")>
<CFSET TestUserTime = CreateODBCDateTime("3/30/2001 4:00:00")>
<CFSET UserTZOffset = DateDiff("h", TestUTCNow, TestUserTime)>
User's TimeZoneOffset = #UserTZOffset# <!--- This SHOULD be -8, but is
only -7! Unless, you make UTCNow equal to "3/30/2001 12:00:01" --->
</CFOUTPUT>
The output of the above hard-coded sample SHOULD be "-8", meaning the user
is in California, 8 hours BEHIND UTC. When displaying dates and times out
of the database for this user, we will first subtract 8 hours from the data.
However, the above code only spits out -7. This is the problem at hand.
Nobody yet has established a better way to automatically determine the
user's time zone other than what I have set forth above. Our way WOULD
work, if the calculation block of code, as I provided above, would do what
it is supposed to. Is this not a bug in CF 4.5?
Additional, just discovered information -- if we LEAVE OFF the "seconds"
part of the user's time/date information as submitted in the hidden form
field, the above code DOES spit out -8. Try it:
<CFOUTPUT>
<CFSET TestUTCNow = CreateODBCDateTime("3/30/2001 12:00:00")>
<CFSET TestUserTime = CreateODBCDateTime("3/30/2001 4:00:")>
<CFSET UserTZOffset = DateDiff("h", TestUTCNow, TestUserTime)>
User's TimeZoneOffset = #UserTZOffset#
</CFOUTPUT>
With the SECONDS missing, it calculates the correct datediff.
What gives?
I appreciate the responses to date -- thank you!
Marc
-----Original Message-----
From: wish wish [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 30, 2001 10:42 AM
To: Fusebox
Subject: Re: [OT] Timezone madness
<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