PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > 开发编程 > JavaScript教程 > 正文

    js如何判断时间是早上,上午,下午,傍晚,晚上

    作者:admin来源:网络浏览:时间:2020-09-30 00:07:50我要评论
    导读:js判断早上好,上午好,下午好,傍晚好,晚上好<script language="javaScript">now = new Date(),hour = now.getHours()if(hour < 6){d...
    js判断早上好,上午好,下午好,傍晚好,晚上好

    <script language="javaScript"> 
    now = new Date(),hour = now.getHours() 
    if(hour < 6){document.write("凌晨好!")} 
    else if (hour < 9){document.write("早上好!")} 
    else if (hour < 12){document.write("上午好!")} 
    else if (hour < 14){document.write("中午好!")} 
    else if (hour < 17){document.write("下午好!")} 
    else if (hour < 19){document.write("傍晚好!")} 
    else if (hour < 22){document.write("晚上好!")} 
    else {document.write("夜里好!")} 

    </script>

    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-69-2365-1.html
    相关热词搜索:
    上一篇:JS合并数组