ASP 格式化时间函数

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

'格式化时间函数
public function formatdate(dateandtime,para)
	on error resume next
	dim y, m, d, h, mi, s, strdatetime
	formatdate = dateandtime
	if not isnumeric(para) then exit function
	if not isdate(dateandtime) then exit function
	y = cstr(year(dateandtime))
	m = cstr(month(dateandtime))
	if len(m) = 1 then m = "0" & m
	d = cstr(day(dateandtime))
	if len(d) = 1 then d = "0" & d
	h = cstr(hour(dateandtime))
	if len(h) = 1 then h = "0" & h
	mi = cstr(minute(dateandtime))
	if len(mi) = 1 then mi = "0" & mi
	s = cstr(second(dateandtime))
	if len(s) = 1 then s = "0" & s
	select case para
		case "1"
			strdatetime = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
		case "2"
			strdatetime = y & "-" & m & "-" & d
		case "3"
			strdatetime = y & "/" & m & "/" & d
		case "4"
			strdatetime = y & "年" & m & "月" & d & "日 " & h & ":" & mi & ":" & s
		case "5"
			strdatetime = m & "-" & d & " " & h & ":" & mi
		case "6"
			strdatetime = m & "/" & d
		case "7"
			strdatetime = m & "月" & d & "日"
		case "8"
			strdatetime = y & "年" & m & "月"
		case "9"
			strdatetime = y & "-" & m
		case "10"
			strdatetime = y & "/" & m
		case "11"
			strdatetime = right(y,2) & "-" &m & "-" & d & " " & h & ":" & mi
		case "12"
			strdatetime = right(y,2) & "-" &m & "-" & d
		case "13"
			strdatetime = m & "-" & d
		case else
			strdatetime = dateandtime
	end select
	formatdate = strdatetime
end function