asp时间函数:2000-2-2变成2000-02-02

来源:百度知道 编辑:UC知道 时间:2024/05/08 21:18:57
如何用ASP的时间函数实现将这样一个时间变成我想要的,请看下面。
2000-2-2变成2000-02-02
有没有直接的函数可以实现的?不然就会很麻烦一个个去判断了。
请高手指教,谢谢。
2007-6-29 9:23:5====>2007-06-29 09:23:05
我找了很久,好像的确没有直接的方法,我现在是用这种方法实现的:
year(now) & "-" &
right("0"&month(now),2) & "-" &
right("0"&day(now),2)&" "&
formatdatetime(now,vbshorttime)&":"&
right("0"&second(now,2)

谢谢各位的指教!

没有 直接的函数 实现 但几行代码就可以写好的
<%
a=year(now)
b=month(now)
c=day(now)
if b<10 then b="0" & b
if c<10 then c="0" & c
t=a & "-" & b & "-" & c
response.write t
%>

'#################
'函数说明new_formatdatetime(datetime,NamedFormat,connstr)
'datetime:时间
'connstr:您要连接各个时间段的字符"-"为2002-02-03;"/"为2002/02/03
'NamedFormat:格式化样式0:2002-02-03
' 1:02-02-03
' 2:02-03
'#################
function new_formatdatetime(datetime,NamedFormat,connstr)
dim datearr
dim datetim,datearr_len,i
if connstr="" then
connstr="-"
end if
if NamedFormat="" then
NamedFormat=0
end if
if isdate(datetime) then
datetim= FormatdateTime(datetime,2)
select case NamedFormat
case 0
datetim=right(date