实用的按照不同时间段显示不同的广告JS脚本内容

因不同时间段需求不同,调用展示的脚本内容也不同,下面通过实用JS脚本,根据时间段来显示不同的广告内容。
如下面的代码:
<script type="text/javascript">
var h = new Date().getHours();
var t = "";
if(h >= 7 && h <= 13){
        t = "<div class='inde_t_ad'><a href='http://www.chinae.org/' target='_blank' rel='nofollow'><img src='/skin/add/a1.jpg' border='0' /></a></div>";        
}else if(h >= 14 && h <= 20){
        t = "广告2";
}
  else if(h >= 21 || h <= 6){
        t = "广告3";
  }
document.getElementById('time_ads').innerHTML = t;
</script>

广告代码分时段显示
早7点-13点显示广告1
14点-20点显示广告2
19点-次日6点显示广告3

具体时间根据自己需要调整使用