ASP问题(2)

来源:百度知道 编辑:UC知道 时间:2024/05/05 18:09:42
function fdate(str)
if len(str) = 1 then str = "0" & str
fdate = str
end function
帮我分析一下上面的代码,谢谢

function fdate(str)
if len(str) = 1 then str = "0" & str '如果str的长度是1,则在str前面加一个0
fdate = str '函数返回处理过的str
end function

这个函数主要用于格式化日期时的月份和天的处理,比如要得到2007-09-01这种格式,就要用到此函数,不处理的话格式是2007-9-1

if len(str) = 1 then str = "0" & str

如果str长度是1,前面加个0