zoukankan      html  css  js  c++  java
  • 万能时间补位代码

    Public Function ForMatDate(DateAndTime, Para) '格式化日期(日期时间,格式) 
    Dim Y, M, D, H, F, S 
    IF Not ISNumeric(Para) Or Not ISDate(DateAndTime) Then Exit Function  
    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  
    F = CStr(Minute(DateAndTime)):IF Len(F) = 1 Then F = "0" & F  
    S = CStr(Second(DateAndTime)):IF Len(S) = 1 Then S = "0" & S  
    Select Case Para 
        Case "0" 
            ForMatDate = Y & "-" & M & "-" & D & " " & H & ":" & F & ":" & S 
        Case "1" 
            ForMatDate = Y & "-" & M & "-" & D & " " & H & ":" & F 
        Case "2" 
            ForMatDate = Y & "-" & M & "-" & D  
        Case "3" 
            ForMatDate = Y & "/" & M & "/" & D  
        Case "4" 
            ForMatDate = Y & "年" & M & "月" & D & "日"  
        Case "5"  
            ForMatDate = M & "-" & D & " " & H & ":" & F  
        Case "6"  
            ForMatDate = M & "/" & D  
        Case "7"  
            ForMatDate = M & "月" & D & "日"  
        Case "8"  
            ForMatDate = Y & "年" & M & "月"  
        Case "9"  
            ForMatDate = Y & "-" & M  
        Case "10"  
            ForMatDate = Y & "/" & M  
        Case "11"  
            ForMatDate = right(Y,2) & "-" &M & "-" & D & " " & H & ":" & F  
        Case "12"  
            ForMatDate = right(Y,2) & "-" &M & "-" & D  
        Case "13"  
            ForMatDate = M & "-" & D  
        Case Else  
            ForMatDate = DateAndTime 
    End Select 
    End Function 
    Response.Write ForMatDate(Now,"2") 
  • 相关阅读:
    清北学堂2019NOIP提高储备营DAY1
    最小生成树--克鲁斯卡尔算法(Kruskal)
    关于队列(还有广度优先搜索的例题)
    染色问题
    行列式的相关知识
    素数筛法
    中国剩余定理(孙子定理)
    AOJ 9.University
    AOJ 8.童年生活二三事
    AOJ 7.Redraiment猜想
  • 原文地址:https://www.cnblogs.com/keringing/p/5118579.html
Copyright © 2011-2022 走看看