'ASP格式化时间函数
functionformatdate(dateandtime,para)
onerrorresumenext
dimy,m,d,h,mi,s,strdatetime
formatdate=dateandtime
ifnotisnumeric(para)thenexitfunction
ifnotisdate(dateandtime)thenexitfunction
y=cstr(year(dateandtime))
m=cstr(month(dateandtime))
iflen(m)=1thenm="0"&m
d=cstr(day(dateandtime))
iflen(d)=1thend="0"&d
h=cstr(hour(dateandtime))
iflen(h)=1thenh="0"&h
mi=cstr(minute(dateandtime))
iflen(mi)=1thenmi="0"&mi
s=cstr(second(dateandtime))
iflen(s)=1thens="0"&s
selectcasepara
case"1"
strdatetime=y&"-"&m&"-"&d&""&h&":"&mi&":"&s
case"2"
strdatetime=y&"-"&m&"-"&d
case"3"
strdatetime=y&"/"&m&"/"&d
case"4"
strdatetime=y&"年"&m&"月"&d&"日"&h&":"&mi&":"&s
case"5"
strdatetime=m&"-"&d&""&h&":"&mi
case"6"
strdatetime=m&"/"&d
case"7"
strdatetime=m&"月"&d&"日"
case"8"
strdatetime=y&"年"&m&"月"
case"9"
strdatetime=y&"-"&m
case"10"
strdatetime=y&"/"&m
case"11"
strdatetime=right(y,2)&"-"&m&"-"&d&""&h&":"&mi
case"12"
strdatetime=right(y,2)&"-"&m&"-"&d
case"13"
strdatetime=m&"-"&d
caseelse
strdatetime=dateandtime
endselect
formatdate=strdatetime
endfunction
|