程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> asp 格式化時間日期

asp 格式化時間日期

編輯:關於ASP編程

      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

    1. 上一頁:
    2. 下一頁:
    Copyright © 程式師世界 All Rights Reserved