JS简单判断晚上中午下午

  • 发布于:2020-05-18
  • 209 人围观

很简单。。大家可以看下。代码如需:   

  <script type="text/javascript">
            var now=(new Date()).getHours();
   if(now>0&&now<=6){
    document.write("午夜好,");
   }else if(now>6&&now<=11){
    document.write("早上好,");
   }else if(now>11&&now<=14){
    document.write("中午好,");
   }else if(now>14&&now<=18){
    document.write("下午好,");
   }else{
    document.write("晚上好,");
   }
   </script>

万企互联
标签: