Js获取当前星期几

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>获取当前星期</title>
 </head>
 <body>
  <script type="text/javascript">
    /**
     *获取当前星期几
     *
    */
    function getWeekDate() {
       var now = new Date();
       var day = now.getDay();
       var weeks = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
       var week = weeks[day];
       return week;
    }
    alert(getWeekDate());
  </script>
 </body>
</html>

来自微信公众号:编程社

程序员日常进阶宝典,欢迎关注!

posted on 2019-09-02 22:26  黑夜开发者  阅读(32390)  评论(1编辑  收藏  举报