asp時間轉化為數字、字串方法

來源:互聯網
上載者:User

asp中我想取時間如2009-8-4 16:03:04中數字,但用cstr函數或別的轉化後都是2009841634,請問怎樣才能使其變為“200984160304”?也就是時間中數字小於10時也顯示兩位。

  <%

  str=now

  str=replace(str," ","")

  str=replace(str,"-","")

  str=replace(str,":","")

  str=replace(str,"上午","")

  str=replace(str,"下午","")

  response.write str

  %>

  '***************************************************

  '函 數 名:getYYYYMMDDHHIISS

  '作    用:根據給定的日期和時間型資料將其轉換為YYYYMMDDHHIISS字串格式

  '參    數:d 日期型資料,t 時間型資料

  '返 回 值:轉換後的字串

  '***************************************************

  Function GetYYYYMMDDHHIISS(d,t)

  YYYY=Year(d)

  MM=Month(d)

  DD=Day(d)

  HH=Hour(t)

  II=Minute(t)

  SS=Second(t)

  If Len(YYYY) =2 then

  YYYY="20" & YYYY

  End If

  If Len(MM)=1 then

  MM="0" & MM

  End If

  If Len(DD)=1 then

  DD="0" & DD

  End If

  If Len(HH)=1 then

  HH="0" & HH

  End If

  If Len(II)=1 then

  II="0" & II

  End If

  If Len(SS)=1 then

  SS="0" & SS

  End If

  GetYYYYMMDDHHIISS=YYYY & MM & DD & HH & II & SS

  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.