码迷,mamicode.com
首页 > 其他好文 > 详细

判断某天是周几

时间:2018-01-31 11:21:15      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:nbsp   return   判断   pos   cti   lan   直接   gpo   blog   

直接上代码

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">
    //判断某天是周几 IE9以上支持
    function getMyDay(date) {
        var week;
        var num = date.getDay();
        switch (num) {
            case 0:
                week = ‘周日‘;
                break;
            case 1:
                week = "周一";
                break;
            case 2:
                week = ‘周二‘;
                break;
            case 3:
                week = "周三";
                break;
            case 4:
                week = "周四";
                break;
            case 5:
                week = ‘周五‘;
                break;
            case 6:
                week = "周六";
                break;
        }
        return week;
    }
    var w1 = getMyDay(new Date("2018-01-30"));
    document.write(w1);
    </script>
</body>

</html>

 

判断某天是周几

标签:nbsp   return   判断   pos   cti   lan   直接   gpo   blog   

原文地址:https://www.cnblogs.com/chenmiaosong/p/8390703.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!