[thelist] cf: adjusting for timezones

isaac forman isaac at members.evolt.org
Mon Jul 17 07:38:58 CDT 2000


> how do i automagically convert a time between timezones?  for example, my
> host is us-based although i'm making a site for the nz timezone (+1200) so
> i need to adjust the time returned by Now().
> i'd rather use a function that just add the required hours, as there's
> daylight saving for half the year, at my end at least.

Previously I've been lazy and used the shitty add method to get a rough time. I
don't know the specific answer, but I suspect your solution will rely in the
functions found in the docs @ Language Reference --> Functions --> International

I believe that you can set your location and time/date formats using some of
these functions. Specifically, you may have some luck with the function

Here's the info straight from the docs:

Returns a structure containing time zone information for the machine on which
this function is executed. The structure contains four elements with the
following keys.

utcTotalOffset -- total offset of the local time in minutes from UTC (Universal
Coordinated Time). A plus sign (+) indicates that a time zone is west of UTC,
such as all of the time zones in North and South America. A minus sign (-)
indicates that a time zone is east of UTC, such as the time zones in Germany.

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 will always be zero. However, for some
countries that do not land exactly on the hour offset, the number will be
between 0 and 60. For example, standard time in Adelaide, Australia has an
offset of 9 hours and 30 minutes from UTC.

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

Good luck - let me know how you go,


More information about the thelist mailing list