-
-
-
-
-
-
- Public Function FormatDate(DateAndTime, para)
- On Error Resume Next
- Dim y, m, d, h, mi, s, strDateTime
- FormatDate = DateAndTime
- If Not IsNumeric(para) Then Exit Function
- If Not IsDate(DateAndTime) Then
- Response.write("错误日期格式")
- Exit Function
- End If
- y = CStr(Year(DateAndTime))
- m = CStr(Month(DateAndTime))
- If Len(m) = 1 Then m = "0" & m
- d = CStr(Day(DateAndTime))
- If Len(d) = 1 Then d = "0" & d
- h = CStr(Hour(DateAndTime))
- If Len(h) = 1 Then h = "0" & h
- mi = CStr(Minute(DateAndTime))
- If Len(mi) = 1 Then mi = "0" & mi
- s = CStr(Second(DateAndTime))
- If Len(s) = 1 Then s = "0" & s
- Select Case para
- 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 & "日"
- 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
- Case Else
- strDateTime = DateAndTime
- End Select
- FormatDate = strDateTime
- End Function
- ss = Now()
- Call FormatDate("2008-10-18 14:34:43","1")
- Response.write FormarDate