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
复制代码

 

posted @   Liu66~  阅读(235)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系统下SQL Server数据库镜像配置全流程详解
· 现代计算机视觉入门之:什么是视频
· 你所不知道的 C/C++ 宏知识
· 聊一聊 操作系统蓝屏 c0000102 的故障分析
· SQL Server 内存占用高分析
阅读排行:
· DeepSeek V3 两周使用总结
· 回顾我的软件开发经历(1)
· C#使用yield关键字提升迭代性能与效率
· 低成本高可用方案!Linux系统下SQL Server数据库镜像配置全流程详解
· 4. 使用sql查询excel内容
点击右上角即可分享
微信分享提示