ASP格式化时间日期(二)
Public Function FormatDT(dt, style) 'style=0 2000-10-10 下午 12:17:45 'style=1 2000-10-10 23:17:45 'style=2 2000-10-10 23:45 'style=3 00-10-10 23:45 'style=4 10-10 23:45 'style=5 2000-10-10 'style=6 00-10-10 'style=7 10-10 'style=8 23H-45M-45S 'style=9 20001010231745 'style=10 0510 上传图片 'style=11 05年10月10日 'style=12 05/10/12 上传图片 Dim nowdate, y, m, d, h, i, s, t, APM, hAPM nowdate = dt y = Year(nowdate) if len(y)=1 then y="0"&y m = Month(nowdate) if len(m)=1 then m="0"&m d = Day(nowdate) if len(d)=1 then d="0"&d h = Hour(nowdate) if len(h)=1 then h="0"&h i = Minute(nowdate) if len(i)=1 then i="0"&i s = Second(nowdate) if len(s)=1 then s="0"&s If h > 12 Then APM = "下午 " hAPM = CStr(CInt(h) Mod 12) Else APM = "上午 " hAPM = h End If Select Case style Case 0 t = y & "-" & m & "-" & d & " " & APM & hAPM & ":" & i & ":" & s Case 1 t = y & "-" & m & "-" & d & " " & h & ":" & i & ":" & s Case 2 t = y & "-" & m & "-" & d & " " & h & ":" & i Case 3 t = Right(y, 2) & "-" & m & "-" & d & " " & h & ":" & i Case 4 t = m & "-" & d & " " & h & ":" & i Case 5 t = y & "-" & m & "-" & d Case 6 t = Right(y, 2) & "-" & m & "-" & d Case 7 t = m & "-" & d Case 8 t = h & "H-" & i & "M-" & s &"S" Case 9 t = y & m & d & h & i & s Case 10'上传 t = Right(y, 2) & m Case 11 t = Right(y, 2) & "年" & m & "月" & d & "日" Case 12 t = Right(y, 2) & "/" & m & "/" & d End Select FormatDT = t End Function