网页获取时间的两种模式
本文最后更新于 1871 天前,其中的信息可能已经有所发展或是发生改变。

1.网页采用javascript获取本地时间

[sourcecode language=”java” title=”demo-js.jsp”]</pre>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<script type="text/javascript">
var time = new Date();
document.write("从客户端传来问候!")
document.write("现在是北京时间:"+time.getHours()+"点,");
if(time.getHours()<11){
document.write("早上好!");}
else if(time.getHours()<13)
document.write("中午好!");
else if(time.getHours()<19)
document.write("下午好!");
else document.write("晚上好!");
</script>
</body>
</html>
<pre>
[/sourcecode]

效果图:

2.网页采用java代码获取服务器时间

[sourcecode language=”java” title=”demo.jsp”]
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8" import="java.util.Date"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<%
Date time = new Date();
out.print("从服务器传来问候!\n");
out.print("现在是北京时间:"+time.getHours()+"点,");
if(time.getHours()<11){
out.print("早上好!");}
else if(time.getHours()<13)
out.print("中午好!");
else if(time.getHours()<19)
out.print("下午好!");
else out.print("晚上好!");
%>
</body>
</html>
[/sourcecode]

效果图:

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇