Applications Home|Email

 Converting local web server time to UTC (GMT) time.

Sometimes you need to know the UTC (GMT) time, but unfortunately there is no in built UTC time zone functionality coming with vbscript when used with ASP. So what do you do? One approach is to use jscript, because jscript has access to the web servers time zone offset and can convert current local time to UTC time. But how do you pass a jscript variable to vbscript? Luckily, they both share the Session and Application objects provided by ASP, so in this example we simply execute a jscript file from our vbscript code and tell jscript to store the UTC value in a session variable. Then you can access this session variable from your vbscript code.

The GetServerGMT routine will return something like: Wed, 01 Feb 2006 15:21:59 UTC.

Function GetServerGMT()

    '// Use JScript to get the current GMT time stamp and store it in Session("ServerGMT")
    Server.Execute "GetServerGMT.asp"
    GetServerGMT = Session("ServerGMT")

End Function

And this is how the GetServerGMT.asp file with the jscript code looks like:

    var od = new Date();
    var nd = od.toGMTString();
    Session("ServerGMT") = nd;



Therefore: For that or this for it.
© www.u229.no