【JavaScript】JS获得指定时间的星期信息
2010-05-19 17:26 Peter Jin 阅读(1858) 评论(0) 编辑 收藏 举报
【要点】JS获得指定时间的星期信息
js实现核心代码如下:
js实现核心代码如下:
1 function getDateWeek(selectedDate)
2 {
3 var year = selectedDate.getYear();
4 var month = selectedDate.getMonth();
5 var day = selectedDate.getDate();
6 var dataInfo = new Date(year, month-1, day);
7 var week = "";
8 switch(dateInfo.getDay())
9 {
10 case 0:
11 week="日";
12 break;
13 case 1:
14 week="一";
15 break;
16 case 2:
17 week="二";
18 break;
19 case 3:
20 week="三";
21 break;
22 case 4:
23 week="四";
24 break;
25 case 5:
26 week="五";
27 break;
28 case 6:
29 week="六";
30 break;
31 }
32 return week;
33 }
2 {
3 var year = selectedDate.getYear();
4 var month = selectedDate.getMonth();
5 var day = selectedDate.getDate();
6 var dataInfo = new Date(year, month-1, day);
7 var week = "";
8 switch(dateInfo.getDay())
9 {
10 case 0:
11 week="日";
12 break;
13 case 1:
14 week="一";
15 break;
16 case 2:
17 week="二";
18 break;
19 case 3:
20 week="三";
21 break;
22 case 4:
23 week="四";
24 break;
25 case 5:
26 week="五";
27 break;
28 case 6:
29 week="六";
30 break;
31 }
32 return week;
33 }