ASP 生成带日期的随机数

时间:2023-03-09 01:20:05
ASP 生成带日期的随机数
<%
Function getRnd()
'****************************************
'返回值:如getRnd(),即输出200808241553464617,为2008年08月24日15时53分46秒4617随机数
'关联函数:formatInt()
'****************************************
getRnd = ""
getRnd = getRnd&formatInt(year(now),4)
getRnd = getRnd&formatInt(month(now),2)
getRnd = getRnd&formatInt(day(now),2)
getRnd = getRnd&formatInt(hour(now),2)
getRnd = getRnd&formatInt(minute(now),2)
getRnd = getRnd&formatInt(second(now),2)
randomize
ranNum=int((9000*rnd)+1000)
getRnd = getRnd&ranNum
End Function Function formatInt(Expression,Digit)
'****************************************
'函数名:formatInt
'作 用:输出Digit位左边带0整数
'参 数:Expression ----要格式化整数
'参 数:Digit ----要格式化位数
'返回值:如006,如FormatIntNumber(6,3),整数5被格式化为006
'关联函数:无
'****************************************
While Len(Expression) < Digit
Expression = "0"&Expression
wend
formatInt = Expression
End Function response.Write(getRnd()&"<br>")
response.Write(formatInt(24,5))'输出00024
%>