经典asp中的当前世界时间 [英] Current Universal time in classic asp

查看:21
本文介绍了经典asp中的当前世界时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在经典 asp 中将当前时间作为通用时间.我知道如何进入 C# 并且我在 c# 中使用以下行 ((DateTime.Now).ToUniversalTime()).ToString("s") 获取通用时间,这段代码给了我这样的时间 2012-07-09T10:29:49

How can I get the current time as Universal time in classic asp. I know how to get in C# and I am getting the universal time in c# with following line ((DateTime.Now).ToUniversalTime()).ToString("s") and this code gives me time like this 2012-07-09T10:29:49

但我想知道经典 asp 中的等价物.谢谢

But I want to know the equivalent in classic asp. Thanks

推荐答案

根据u229.no,VBScript 中没有任何内置方法可以转换为 UTC.

According to u229.no, there isn't any built-in way in VBScript to convert to UTC.

看看下面作者提供的使用 JScript 的代码,以及如何从 VBScript 调用它.

Take a look at the code the author provided below which uses JScript, and how you can call this from VBScript.

GetServerGMT 例程将返回如下内容:Wed, 01 Feb 2006 15:21:59 UTC.

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 

这就是带有 jscript 代码的 GetServerGMT.asp 文件的样子:

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

<%@language="jscript"%>
<%
    var od = new Date();
    var nd = od.toUTCString();
    Session("ServerGMT") = nd;
%> 

您也可以使用其他 jscript 方法.

这篇关于经典asp中的当前世界时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆