Jeff,

Thanks for the response, but I think you've missed it, unless i am totally
misreading the recommendation you've made.  I explain:

The definition of the function GetTimeZoneInfo() is "Returns a structure
containing time zone information FOR THE MACHINE ON WHICH THIS FUNCTION IS
EXECUTED."  The function is always executed on the server, not on the user's
machine, yes?

This will not help at all in determining what time zone a WEB VISITOR is in,
as far as I can tell.  It only returns the time zone info of the server,
which we already know.

We currently use DateConvert("Local2UTC", Now()) to get the current UTC
time, which we compare against the time on the user's computer as they
submitted in a hidden form field.  The difference between UTC and the user's
time as submitted determines the user's time zone.

Please re-read my original post if this is not clear; and I can always
provide additional code if necessary.

Marc



-----Original Message-----
From: Jeff Peters [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 30, 2001 9:47 AM
To: Fusebox
Subject: Re: [OT] Timezone madness


Don't go mad! ;>

May I suggest you use the GetTimeZoneInfo() function?  It creates a lovely
little structure with just the information you need:

utcTotalOffset: offset of the local time in minutes from UTC.  Positive
values
are west of Greenwich; negative values are east.

utcHourOffset: offset in hours of local time from UTC.

utcMinuteOffset: offset in minutes after the hours offset is taken into
account. For North America, this is zero.  Some countries have part-hour
offsets, like Newfoundland, Iran, India, and parts of Australia.

isDSTOn -- True if Daylight Savings Time (DST) is on in the host machine;
False
if DST is off.

So, for your app, the code would become:

<cfset timeInfo = GetTimeZoneInfo()>
<cfoutput>
        User's TimeZoneOffset = #timeInfo.utcHourOffset#
</cfoutput>

Ain't it cool?!

- Jeff

On 30 Mar 2001, at 7:56, Marc Funaro wrote:

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