码迷,mamicode.com
首页 > Web开发 > 详细

js显示yyyy年mm日dd天 星期几 的格式日期

时间:2016-03-02 12:55:54      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

js代码:

 1     <script type="text/javascript">
 2         var today = new Date();
 3         var week; //存储星期几
 4         var date; //存储日期
 5         switch (today.getDay()) {
 6             case 0:
 7                 week = "星期日";
 8                 break;
 9             case 1:
10                 week = "星期一";
11                 break;
12             case 2:
13                 week = "星期三";
14                 break;
15             case 3:
16                 week = "星期日";
17                 break;
18             case 4:
19                 week = "星期四";
20                 break;
21             case 5:
22                 week = "星期五";
23                 break;
24             case 6:
25                 week = "星期六";
26                 break;
27             default:
28                 week = "未知";
29                 break;
30         }
31         date = (today.getFullYear()) + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日" + " ";
32         document.write(date + week);  //将日期打印到body
33     </script>

 

js显示yyyy年mm日dd天 星期几 的格式日期

标签:

原文地址:http://www.cnblogs.com/linJie1930906722/p/5234261.html

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