VBScript ISO8601 [英] VBScript ISO8601
本文介绍了VBScript ISO8601的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 VBScript 中,FormatDateTime
是否支持 ISO 8601?
In VBScript, does FormatDateTime
have ISO 8601 support?
如果没有,我将如何用它编写这样的函数?
If not, how would I write such function with it?
例如:
Response.Write FormatAsISO8601(#05/04/2011#)
Function FormatAsISO8601(datetime)
...
End Function
推荐答案
这是我需要的 Chris 类的具体代码,优化了一点:
Here is the specific code I needed from Chris' class, a bit more optimized:
Public Function ToIsoDateTime(datetime)
ToIsoDateTime = ToIsoDate(datetime) & "T" & ToIsoTime(datetime) & CurrentTimezone
End Function
Public Function ToIsoDate(datetime)
ToIsoDate = CStr(Year(datetime)) & "-" & StrN2(Month(datetime)) & "-" & StrN2(Day(datetime))
End Function
Public Function ToIsoTime(datetime)
ToIsoTime = StrN2(Hour(datetime)) & ":" & StrN2(Minute(datetime)) & ":" & StrN2(Second(datetime))
End Function
Private Function StrN2(n)
If Len(CStr(n)) < 2 Then StrN2 = "0" & n Else StrN2 = n
End Function
这篇关于VBScript ISO8601的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文