asp格式化日期时间(显示) 的代码

来源:转载

asp格式化日期时间(显示) 

' ============================================ 
' 格式化日期时间(显示) 
' 参数:n_Flag 
' 1:"yyyy-mm-dd hh:mm:ss" 
' 2:"yyyy-mm-dd" 
' 3:"hh:mm:ss" 
' 4:"yyyy年mm月dd日" 
' 5:"yyyymmdd" 
' 6:"yyyymmddhhmmss"
' 7:"yy-mm-dd"  
' 8:"yy-mm-dd hh:mm:ss" 
' 9:"yyyy年mm月" 
' 10:"mm/dd/yyyy" 
' ============================================ 
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))
if y = "1900" then Exit Function 
m = right("0"&month(s_Time),2) 
d = right("0"&day(s_Time),2)
h = right("0"&hour(s_Time),2)
mi = right("0"&minute(s_Time),2)
s = right("0"&second(s_Time),2)

Select Case n_Flag 
Case 1 
Format_Time = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s 
Case 2 
Format_Time = y & "-" & m & "-" & d 
Case 3 
Format_Time = h & ":" & mi & ":" & s 
Case 4 
Format_Time = y & "年" & m & "月" & d & "日" 
Case 5 
Format_Time = y & m & d 
case 6 
Format_Time= y & m & d & h & mi & s
case 7
Format_Time= right(y,2) & "-" & m & "-" & d
case 8
Format_Time= right(y,2) & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s 
Case 9 
Format_Time = y & "年" & m & "月"
Case 10 
Format_Time = m & "/" & d & "/" & y & "/"
End Select 
End Function 

分享给朋友:
您可能感兴趣的文章:
随机阅读: