asp 时间的格式化..

来源:百度知道 编辑:UC知道 时间:2024/07/08 12:38:57
我想让 2007-9-9 9:35:00
显示成 2007-09-09 09:35:00

是通过函数Now()得到的时间写入数据库的。

<%
Function format_now(n)
dim n_temp(4)
n_temp(0)=Month(n)
n_temp(1)=day(n)
n_temp(2)=Hour(n)
n_temp(3)=Minute(n)
n_temp(4)=Second(n)
for i = 0 to 4
if len(n_temp(i))=1 then n_temp(i)="0"&n_temp(i)
next
format_now=year(n)&"-"&n_temp(0)&"-"&n_temp(1)&" "&n_temp(2)&":"&n_temp(3)&":"&n_temp(4)
End Function

Response.Write(format_now(now()))
%>