[thelist] TimeZone change

Ben Henick persist1 at io.com
Wed Nov 13 08:24:01 CST 2002


On Wed, 13 Nov 2002, Stevenson Ngila wrote:

> I want to have a web page that runs in the server, the page should identify
> time zone changes i.e. currently the time difference between Kenya and UK is
> 3hrs, but at times the difference can be 2hrs.
>
> This page should be executing every one day and getting the time difference
> and update a DB.

Well, PHP and JavaScript both have functions to return GMT.

PHP4:  time() should return a standard Unix timestamp, which you can
compare against the local time recorded by the server (presumably with
localtime()).

JavaScript:  Date.getTimeZoneOffset() (where Date instead refers to a
variable which contains the return value of an explicitly created Date
object) returns the offset between the server time and GMT in minutes.

A cursory examination of VBScript's function list suggests no comparable
support, but in point of fact I know little of VBScript.

If I understand your question properly, then it doesn't make much sense as
to why the DB needs to store timezone offsets.  Nor would it be necessary
to schedule/cron something like that - just place the offset values in a
table of their own, and if a SELECT for the current date returns null,
insert a value.

If you are only concerned with a single country's implementation of
ST/DST, said implementation will be described by law and can be applied as
an algorithm in the form of a cron'ed or scheduled script without the need
for any hassles:

if (date/time is within dst range) { apply dst offset } else
   { apply standard offset }

Given the support available, it follows that the OS (regardless of make)
ALWAYS "knows" the offset from GMT.  So in fact, someone else here is
probably in a position to provide a more elegant solution.


--
Ben Henick
Web Author At-Large              Managing Editor
http://www.io.com/persist1/      http://www.digital-web.com/
persist1 at io.com                  bmh at digital-web.com
--
"Are you pondering what I'm pondering, Pinky?"
"I think so, Brain, but... (snort) no, no, it's too stupid."
"We will disguise ourselves as a cow."
"Oh!" (giggles) "That was it exactly!"





More information about the thelist mailing list