時刻によってメッセージを変える(getHours)
<html>
<head>
<title>時刻によってメッセージを変える</title>
</head>
<body>
<script language="JavaScript">
<!--
//時間の取得
today = new Date();
h = today.getHours();
//時間によってのメッセージ出力
if((h >= 6) && (h < 11))
document.write("おはようございます。");
else if((h >= 11) && (h < 18))
document.write("こんにちは。");
else
document.write("こんばんは。");
//-->
</script>
</body>
</html>
〔 実行する 〕