如何格式化以最小的分离器和时区在VBScript日期时间? [英] How to format a datetime with minimal separators and timezone in VBScript?

查看:160
本文介绍了如何格式化以最小的分离器和时区在VBScript日期时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#以下code:

I have the following code in C#:

DateTime dt = GetDateTime();
string formatted = dt.ToString("yyyyMMddTHHmmsszz");

这在下面的格式返回日期:

which returns a date in the following format:

20100806T112917+01

我希望能够得到在VBScript相同的结果(对于一个传统的ASP应用程序)。我得到的UTC偏移信息,或者转换为UTC时间这是特别重要的。

I would like to be able to get the same results in VBScript (for a legacy ASP application). It is especially important that I get the UTC offset information, or have the time converted to UTC.

我该怎么办呢?

推荐答案

有关日期格式,我喜欢用从VBScript的.NET StringBuilder类:

For date formatting, I like using the .NET StringBuilder class from VBScript:

Option Explicit

Dim sb : Set sb = CreateObject("System.Text.StringBuilder")
sb.AppendFormat "{0:yyyyMMddTHHmmsszz}", Now()
Response.Write sb.ToString()

以上的回报:

20100806T201139-07

这假定您已经.NET Web服务器上安装。

This assumes that you have .NET installed on your web server.

这篇关于如何格式化以最小的分离器和时区在VBScript日期时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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