利用UNIX时间戳来计算ASP的在线时间

<%@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>无标题文档</title>
</head>
<%Function ToUnixTime(strTime, intTimeZone)
If IsEmpty(strTime) or Not IsDate(strTime) Then strTime = Now
If IsEmpty(intTimeZone) or Not isNumeric(intTimeZone) Then intTimeZone = 0
ToUnixTime = DateAdd("h",-intTimeZone,strTime)
ToUnixTime = DateDiff("s","1970-01-01 00:00:00", ToUnixTime)
End Function%>

<%dim mm1
mm1=ToUnixTime("2016-09-18 16:30:00",+8)

dim mm2
mm2=ToUnixTime(now(),+8)
%>
<%=mm1%><br><%=mm2%>
<br>
<%=mm1-mm2%>
<body>
</body>
</html>

posted @ 2016-09-18 16:37  Xander_1  阅读(593)  评论(0编辑  收藏  举报