日期:2009-12-21  浏览次数:20929 次

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