发表于:2011-07-04 00:00:00来源:SOUAB.COM人气:3195
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Asp人性化时间函数(分钟/小时/天/月前)</title>
</head>
<body>
<%
function ShowDate(Dates)
diff=DateDiff("s",Dates,now())
if diff<=59 then
response.Write(diff)
response.Write("秒前")
end if
if diff>=60 and diff<3600 then
response.Write(DateDiff("n",Dates,now()))
response.Write("分钟前")
end if
if diff>=3600 and diff<86400 then
response.Write(DateDiff("h",Dates,now()))
response.Write("小时前")
end if
if diff>=86400 and diff<604800 then
response.Write(DateDiff("d",Dates,now()))
response.Write("日前")
end if
if diff>=604800 and diff<2592000 then
response.Write(DateDiff("ww",Dates,now()))
response.Write("星期前")
end if
if diff>=2592000 and diff<31536000 then
response.Write(DateDiff("m",Dates,now()))
response.Write("个月前")
end if
if diff>=31536000 then
response.Write(DateDiff("yyyy",Dates,now()))
response.Write("年前")
end if
end function
ShowDate(""&date()-3&"")
Response.write("<BR><BR>")
ShowDate("2010-5-10")
Response.write("<BR><BR>")
ShowDate(""&now()&"")
%>
</body>
</html>