在這裡插入程式碼片
```<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>分時問候</title>
</head>
<body>
<div>
<img src="上午好.gif" alt="" id="tp">
</div>
<script>
var today = new Date("2019-6-15 12:00");
//document.write(today);括號裡面可以設定時間,如果不寫,則為預設時間
var today = new Date();
var time = today.getHours();
var aa = document.getElementById("tp")
if (time>=0 && time<12){
aa.src="1.gif"
document.write('親,上午好,好好寫程式碼')
}else if(time>=12 && time<18){
aa.src="2.gif"
document.write('親,下午好,好好寫程式碼')
}else{
aa.src="3.gif"
document.write('親,晚上好,好好寫程式碼')
}
</script>
</body>
</html>