⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.asp

📁 implementation of survey
💻 ASP
字号:
<%
' access sub that test whether an authenticated session has been started
sub access()
	dim extention
	' if session is not properly authenticated
	if session("access") <> "yes" then
		' close session
		session("access") = ""
		' redirect to authentication.asp with error message
		response.redirect("authentication.asp?message=denied")
	end if
end sub
' timeStamp function that returns a unix timestamp
function timeStamp(dt)
	dim ts
	' creates timestamp of current VBScript date and time expression
	if dt = "now" then
		ts = dateDiff("s", "01/01/1970 00:00:00", now)
	' creates timestamp of specified VBScript date and time expression
	else
		ts = dateDiff("s", "01/01/1970 00:00:00", dt)
	end if
	timeStamp = ts
end function
' tsDate function that returns formated date of specified timestamp
function tsDate(time_stamp)
	dim ts, d_year, d_month, d_day
	' convert unix timestamp to a VBScript date and time expression
	ts = dateAdd("s", time_stamp, "01/01/1970 00:00:00")
	' retreive year
	d_year = year(ts)
	' retrieve month and add '0' prefix if month is smaller than 10
	d_month = month(ts)
	if len(d_month) = 1 then d_month = "0" & d_month end if
	' retrieve day and add '0' prefix if day is smaller than 10
	d_day = day(ts)
	if len(d_day) = 1 then d_day = "0" & d_day end if
	' concatenate date using yyyy-mm-dd format
	tsDate = d_year & "-" & d_month & "-" & d_day
end function
' tsTime function that returns formated time of specified timestamp
function tsTime(time_stamp)
	dim ts, t_hour, t_minute, t_second
	' convert unix timestamp to a VBScript date and time expression
	ts = dateAdd("s", time_stamp, "01/01/1970 00:00:00")
	' retrieve hour and add '0' prefix if hour is smaller than 10
	t_hour = hour(ts)
	if len(t_hour) = 1 then t_hour = "0" & t_hour end if
	' retrieve minutes and add '0' prefix if minutes are smaller than 10
	t_minute = minute(ts)
	if len(t_minute) = 1 then t_minute = "0" & t_minute end if
	' retrieve seconds and add '0' prefix if seconds are smaller than 10
	t_second = second(ts)
	if len(t_second) = 1 then t_second = "0" & t_second end if
	' concatenate time using hh:mm:ss format
	tsTime = t_hour & ":" & t_minute & ":" & t_second
end function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -