asp訂單號 不重復
超強固定的18位隨機數,日期時間+4位隨機數,永不重復
<%
y=cstr(year(now()))
m=cstr(month(now()))
If len(m)=1 Then
m="0"&m
end if
d=cstr(day(now()))
If len(d)=1 Then
d="0"&d
end if
h=cstr(hour(now()))
If len(h)=1 Then
h="0"&h
end if
n=cstr(minute(now()))
If len(n)=1 Then
n="0"&n
end if
s=cstr(second(now()))
If len(s)=1 Then
s="0"&s
end if
str_now=y&""&m&""&d&""&h&""&n&""&s
Function gen_key(digits)
dim char_array(10)
char_array(1) = "1"
char_array(2) = "2"
char_array(3) = "3"
char_array(4) = "4"
char_array(5) = "5"
char_array(6) = "6"
char_array(7) = "7"
char_array(8) = "8"
char_array(9) = "9"
randomize
do while len(output) < digits
num = char_array(Int((9 - 1 + 1) * Rnd + 0))
output = output + num
loop
gen_key = str_now & output
End Function
strrad=gen_key(4)
response.Write(strrad)
%>