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