ASP程序,把2006-9-9 9:48:13变成20090909094813怎么写?

来源:百度知道 编辑:UC知道 时间:2024/06/24 16:45:49
也就是说,把now()日期转换成数字或串
数字,谢谢
一楼的大体可以,但数位不对,9点48变成09048013了,这是不希望被看到的
代码最好完整一点,二楼的不好使

nian=year(now())
yue=month(now())
if yue<10 then
yue="0"&yue
endif
ri=day(now())
if ri<10 then
ri="0"&ri
end if
hourtime=hourtime(now())
if hourtime<10 then
hourtime="0"&hourtime
end if
.............
nowtime=nian&yue&ri&hourtime&......

ASP中不支持Format,所以二楼的方法在ASP里行不通,你可以用Year,Month等函数来实现转换功能,以下为简单函数
'************************************************
'** 转换日期(如:20060101120000)
'************************************************
Private Function FormatDate(strDate)
FormatDate = Right(CStr("2000" & Year(strDate)),4) & _
Right(CStr("00" & Month(strDate)),2) & _
Right(CStr("00" & Day(strDate)),2) & _
Right(CStr("00" & Hour(strDate)),2) & _
Right(CStr("00" & Minute(strDate)),2) & _
Right(CStr("00" & Second(strDate)),2)
End Functio