ASP日期格式

来源:百度知道 编辑:UC知道 时间:2024/06/01 22:38:48
网页中显示日期的问题,例如8月21日现在显示的是8-21,想把它变成08-21,8月6日现在显示的是8-6把它变成08-06,请教各位老师怎么修改这段代码?<%=month(rs("createdate"))%>-<%=day(rs("createdate"))%>

<%=month(rs("createdate"))%>
改成
<%tedate=month(rs("createdate"))
if tedate<10 then
response.write"0"&tedate
else
response.write tedate
end if%>
<%=day(rs("createdate"))%>
改成
<%daydate=day(rs("createdate"))
if daydate<10 then
response.write "0"&daydate
else
response.write daydate
end if%>

<%
month1=month(rs("createdate"))
day1=day(rs("createdate"))
if month(rs("createdate"))<10 or day(rs("createdate"))<10 then
month1="0"&month(rs("createdate"))
day1="0"&day(rs("createdate"))
end if
m=month1&"-"&day1
response.write m
%>

增加一个函数
function fd(wd)
if len(wd)<2 then
wd="0"&wd
end if
fd=wd
end function

使用:
<%=f