How to get a unix timestamp timezone adjusted from VBScript clientside

Hi All,

As usual timezones are the bane of my life, here is another few hours that I'll never get back.

---
How to get a Unix timestamp timezone adjusted from VBScript (clientside, not ASP)

So you are using VBScript (again, not ASP, i.e. there is no IIS web server) and you want to pass a timezone adjusted unix timestamp to a server side script such as PHP.

You can not use Session.LCID because you are not using ASP, so you need to look at the local PC to determine the timezone.

First step is to retrieve timezone from the registry of the local machine. Now of course this assumes that the local machine has the correct time and timezone information, but then you are writing a client side script so that's a problem for your client, right?

function UDate(oldDate)
Dim od
Dim atb
Dim oShell
Dim offsetMin
Dim nd

od = oldDate

set oShell = CreateObject("WScript.Shell")
atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\" &_
"Control\TimeZoneInformation\ActiveTimeBias"

offsetMin = oShell.RegRead(atb)

nd = dateadd("n", offsetMin, od)

UDate = DateDiff("s", "01/01/1970 00:00:00", nd)

end function

---
Regards, Simon Hutchison
http://www.econfirm.com.au/

Comments

出張ホスト said…
This comment has been removed by a blog administrator.
家出 said…
This comment has been removed by a blog administrator.
救援部 said…
This comment has been removed by a blog administrator.
プロフ公開 said…
This comment has been removed by a blog administrator.
セフレ said…
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
チェッカー said…
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
グリー said…
This comment has been removed by a blog administrator.
セレブ said…
This comment has been removed by a blog administrator.

Popular posts from this blog

PHP timezones explained

iPhone Internet Tethering settings