这个ASP提取时间的代码,咋有问题!

来源:百度知道 编辑:UC知道 时间:2024/06/17 14:48:38
dingdan=now()
t1=month(now)
if len(t1)=1 then t1="0"&t1 end if
t2=day(now)
if len(t2)=1 then t2="0"&t2 end if
t3=hour(now)
if len(t3)=1 then t3="0"&t3 end if
t4=minute(now)
if len(t4)=1 then t4="0"&t4 end if
t5=seconed(now)
if len(t5)=1 then t5="0"&t5 end if
dingdan=year(now)&t1&t2&t3&t4&t5

我想得到 的应该是 2008621091456

可现在是 2008621上午091456 我该怎样办,才能把上午去掉

在获取秒的时候函数写错了,应该是second。改过来就正常了

错误行: t5=seconed(now)

应为 t5 = second(now)

正确代码:

<%
dingdan = now()
t1 = month(now)
if len(t1)=1 then t1 = "0"&t1 end if
t2 = day(now)
if len(t2)=1 then t2 = "0"&t2 end if
t3 = hour(now)
if len(t3)=1 then t3 = "0"&t3 end if
t4 = minute(now)
if len(t4) = 1 then t4 = "0"&t4 end if
t5 = second(now)
if len(t5) = 1 then t5 ="0"&t5 end if
dingdan = year(now)&t1&t2&t3&t4&t5
response.write dingdan
%>

给你一个我常用的格式化时间函数:

Function FormatTime(s_Time, n_Flag)
Dim y, m, d, h, mi, s
FormatTime = ""
If IsDate(s_Time) = False Then Exit Function
y = cstr(year(s_Time))
m = cstr(month(s_Time))
If len(m) = 1 Then m = "0" & m
d = cstr(day(s_Time))
If len(d) = 1 Then d = "0" & d
h = cstr(hour(s_Time