编写ASP程序:要求根据系统时间来判断是上午、中午、下午、还是晚上。

来源:百度知道 编辑:UC知道 时间:2024/06/15 01:42:13
假设定6:00-12:00为上午,12:00-14:00为中午,14:00-19:00为下午,19:00-06:00为晚上。

<%
thetime=hour(time)
if thetime>=6 and thetime=<11 then
response.write("早上")
end if

if thetime=>12 and thetime=<13 then
response.write("中午")
end if

if thetime=>14 and thetime=<18 then
response.write("下午")
end if

if thetime=>19 and thetime=<23 then
response.write("晚上")
end if

if thetime=>0 and thetime=<5 then
response.write("凌晨")
end if

%>

siptem 的回答并不是根据系统时间,而是服务器的时间。如果时间设置不正确或者非同一时区的用户就会不正常。