' 格式化时间(显示)
' 参数:n_Flag
' 1:"yyyy-mm-dd hh:mm:ss"
' 2:"yyyy-mm-dd"
' 3:"hh:mm:ss"
' 4:"yyyy年mm月dd日"
' 5:"yyyymmdd"
' 6:"ymdhms"
' 7:"m-d"
<%
nowtime = "2012-11-15 18:27:06"
%>
演示 1:<%=Format_Time(nowtime,"1")%><br />
结果 1:2012-11-15 18:27:06<hr>
演示 2:<%=Format_Time(nowtime,"2")%><br />
结果 2:2012-11-15<hr>
演示 3:<%=Format_Time(nowtime,"3")%><br />
结果 3:18:27:06<hr>
演示 4:<%=Format_Time(nowtime,"4")%><br />
结果 4:2012年11月15日<hr>
演示 5:<%=Format_Time(nowtime,"5")%><br />
结果 5:20121115<hr>
演示 6:<%=Format_Time(nowtime,"6")%><br />
结果 6:20121115182706<hr>
演示 7:<%=Format_Time(nowtime,"7")%><br />
结果 7:11-15<hr>
<%
Function Format_Time(s_Time, n_Flag)
Dim y, m, d, h, mi, s
Format_Time = ""
If IsDate(s_Time) = False Then Exit Function
y = cstr(year(s_Time))
m = cstr(month(s_Time))
If len(m) = 1 Then m = "0" & m
d = cstr(day(s_Time))
If len(d) = 1 Then d = "0" & d
h = cstr(hour(s_Time))
If len(h) = 1 Then h = "0" & h
mi = cstr(minute(s_Time))
If len(mi) = 1 Then mi = "0" & mi
s = cstr(second(s_Time))
If len(s) = 1 Then s = "0" & s
Select Case n_Flag
Case 1
' yyyy-mm-dd hh:mm:ss
Format_Time = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
Case 2
' yyyy-mm-dd
Format_Time = y & "-" & m & "-" & d
Case 3
' hh:mm:ss
Format_Time = h & ":" & mi & ":" & s
Case 4
' yyyy年mm月dd日
Format_Time = y & "年" & m & "月" & d & "日"
Case 5
' yyyymmdd
Format_Time = y & m & d
Case 6
' yyyymmdd
Format_Time = y & m & d & h & mi & s
Case 7
' m-d
Format_Time = m & "-" & d
End Select
End Function
%>