asp 格式化時間日期

來源:互聯網
上載者:User

  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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.