请问如何用VBS来定义时间格式
关注:66 答案:3 手机版
解决时间 2021-02-08 14:09
- 提问者网友:話仳情亼鎂
- 2021-02-07 16:41
我获取的时间默认是这样的 2009-1-20 1:2:9我想将其转化为这样 2009-01-20 01:02:09请问应该如何操作啊谢谢
最佳答案
- 二级知识专家网友:距离和很远
- 2021-02-07 17:28
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 "<br>"
response.Write formatdatetimes(now)
%>
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 "<br>"
response.Write formatdatetimes(now)
%>
全部回答
- 1楼网友:长街听风
- 2021-02-07 19:21
d=date()
Format(d,"YYYY-MM-DD HH:MM:SS")
- 2楼网友:小河边唱歌
- 2021-02-07 18:45
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 "<br>"
response.write formatdatetimes(now)
%>
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!