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
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.
How do I do that?
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()
The above returns:
20100806T201139-07
This assumes that you have .NET installed on your web server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With