zoukankan      html  css  js  c++  java
  • ASP格式化时间日期(一)

    Function FormatDate(DateAndTime, Format)
      On Error Resume Next
      Dim yy,y, m, d, h, mi, s, strDateTime
      FormatDate = DateAndTime
      If Not IsNumeric(Format) Then Exit Function
      If Not IsDate(DateAndTime) Then Exit Function
      yy = CStr(Year(DateAndTime))
      y = Mid(CStr(Year(DateAndTime)),3)
      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 Format
      Case "1"
        strDateTime = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
      Case "2"
        strDateTime = yy & m & d & h & mi & s
      Case "3"
        strDateTime = yy & m & d & h & mi
      Case "4"
        strDateTime = yy & "" & m & "" & d & ""
      Case "5"
        strDateTime = m & "-" & d
      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 = y & "-" & m & "-" & d
      Case "12"
        strDateTime = y & "/" & m & "/" & d
      Case "13"
        strDateTime = yy & "." & m & "." & d
      Case "14"
        strDateTime = yy & "-" & m & "-" & d
      Case Else
        strDateTime = DateAndTime
      End Select
      FormatDate = strDateTime
    End Function
  • 相关阅读:
    2014-12-28 iframe,style,body style
    2014-12-25 网页基础,html。
    2014-12-19 特殊集合:stack、queue、Hashtable
    2014-12-18 集合
    2014-12-16 多维数组
    2014-12-15 数组
    2014-12-14 跳转语句,while循环,各种类的用法
    combobox DataGridView
    面向对象(重载、封装、继承、抽象)
    winform
  • 原文地址:https://www.cnblogs.com/liuswi/p/2754619.html
Copyright © 2011-2022 走看看