获取网络时间,在不同时间触发事件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>時(shí)間事件</title>
</head>
<body>
</body>
<script>
var int_time=new Date();//使用Date獲取網(wǎng)絡(luò)時(shí)間;
function title(){
var sys_time= int_time.getHours();//這里只需要整點(diǎn)時(shí)間,所以我提取的是"時(shí)";
console.log(typeof?sys_time)//可以輸出變量名看出來(lái),這個(gè)變量是Number類型;
if(sys_time>0&&sys_time<=6){
alert("再睡會(huì)就天亮了");
}? if(sys_time>6&&sys_time<12){
alert('堅(jiān)持一下,要吃午飯了');
}if(sys_time>=12&&sys_time<18){
alert('午飯已經(jīng)吃過(guò)了,晚飯還遠(yuǎn)嗎?');
}if(sys_time>=18&&sys_time<=23){
alert('忙了一天,放松一下,可以做一下愛做的事了');
}
}
title()
</script>
</html>
?
//做這種時(shí)間事件的方法很多,本次就分享這一個(gè),希望對(duì)你會(huì)有幫助.
轉(zhuǎn)載于:https://www.cnblogs.com/changx/p/10843764.html
總結(jié)
以上是生活随笔為你收集整理的获取网络时间,在不同时间触发事件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 防火墙综合实验
- 下一篇: 《如龙8》官宣 桐生一马+春日一番双主角