请问如何用VBS来定义时间格式

我获取的时间默认是这样的 2009-1-20 1:2:9我想将其转化为这样 2009-01-20 01:02:09请问应该如何操作啊谢谢
2026年09月17日 08:54
有2个网友回答
网友(1):

VBS里没有format()函数,简单的给你封个函数将就用吧
function formatdatetimes(datetime)

yy = year(datetime)
mn = month(datetime)
dd = day(datetime)
hh = hour(datetime)
mm = minute(datetime)
ss = second(datetime)

if cint(mn) <10 then mn = "0"&mn
if cint(dd) <10 then dd = "0"&dd

if cint(hh) <10 then hh = "0"&hh
if cint(mm) <10 then mm = "0"&mm
if cint(ss) <10 then ss = "0"&ss

formatdatetimes = yy &"-"& mn &"-"& dd &" "& hh &":"& mm & ":" & ss
end function

response.Write formatdatetimes("2009-1-20 1:2:9")
response.Write "
"
response.Write formatdatetimes(now)
%>

网友(2):

d=date()
Format(d,"YYYY-MM-DD HH:MM:SS")