1 <mce:script type="text/javascript">
2 <!--
3 //当天
4 function showToDay()
5 {
6 var Nowdate=new Date();
7 M=Number(Nowdate.getMonth())+1
8 return Nowdate.getYear()+"-"+M+"-"+Nowdate.getDate();
9 }
10
11
12 //本周第一天
13 function showWeekFirstDay()
14
15 {
16 var Nowdate=new Date();
17 var WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);
18 return WeekFirstDay;
19 }
20 //本周最后一天
21 function showWeekLastDay()
22 {
23 var Nowdate=new Date();
24 var WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);
25 var WeekLastDay=new Date((WeekFirstDay/1000+6*86400)*1000);
26 return WeekLastDay;
27 }
28 //本月第一天
29 function showMonthFirstDay()
30 {
31 var Nowdate=new Date();
32 var MonthFirstDay=new Date(Nowdate.getYear(),Nowdate.getMonth(),1);
33 return MonthFirstDay;
34 }
35
36 //本月最后一天
37
38 function showMonthLastDay()
39 {
40 var Nowdate=new Date();
41 var tmpDate=new Date(Nowdate.getYear(),Nowdate.getMonth()+1,1);
42 //tmpDate.setDate(tmpDate.getDate() -1);
43 //return new Date(Nowdate.getYear(),Nowdate.getMonth(),tmpDate.getDate());
44 var MonthLastDay=new Date(tmpDate-86400000);
45 return MonthLastDay;
46
47 }
48
49
50 //本季第一天
51 function showquarterFirstDay()
52 {
53 var Nowdate=new Date();
54 if(Nowdate.getMonth()<3)
55 return new Date(Nowdate.getYear(),0,1);
56 else if(Nowdate.getMonth()>2 && Nowdate.getMonth()<6)
57 return new Date(Nowdate.getYear(),3,1);
58 else if(Nowdate.getMonth()>5 && Nowdate.getMonth()<9)
59 return new Date(Nowdate.getYear(),6,1);
60 else if(Nowdate.getMonth()>8)
61 return new Date(Nowdate.getYear(),9,1);
62 }
63
64 //本季最后一天
65 function showquarterLastDay()
66 {
67 var Nowdate=new Date();
68
69 if(Nowdate.getMonth()<3)
70 return new Date(Nowdate.getYear(),2,31);
71 else if(Nowdate.getMonth()>2 && Nowdate.getMonth()<6)
72 return new Date(Nowdate.getYear(),5,30);
73 else if(Nowdate.getMonth()>5 && Nowdate.getMonth()<9)
74 return new Date(Nowdate.getYear(),8,30);
75 else if(Nowdate.getMonth()>8)
76 return new Date(Nowdate.getYear(),11,31);
77 }
78
79
80 //本年第一天
81 function showyearFirstDay()
82 {
83 var Nowdate=new Date();
84 var yearFirstDay=new Date(Nowdate.getYear(),0,1);
85 return yearFirstDay;
86 }
87
88 //本年最后一天
89 function showyearLastDay()
90 {
91 var Nowdate=new Date();
92 var yearLastDay=new Date(Nowdate.getYear(),11,31);
93 return yearLastDay;
94 }
95
96
97 //当前月
98 function showmonthCurrent()
99 {
100 var Nowdate=new Date();
101 var Month=Nowdate.getMonth()+1;
102 Month=(Month<10)?'-0'+Month:'-'+Month;
103 return Nowdate.getYear()+Month;
104 }
105
106 //本季开始年月
107 function showquarterFirstMonth()
108 {
109 var Nowdate=new Date();
110 if(Nowdate.getMonth()<3)
111 return Nowdate.getYear()+'-01';
112 else if(Nowdate.getMonth()>2 && Nowdate.getMonth()<6)
113 return Nowdate.getYear()+'-04';
114 else if(Nowdate.getMonth()>5 && Nowdate.getMonth()<9)
115 return Nowdate.getYear()+'-07';
116 else if(Nowdate.getMonth()>8)
117 return Nowdate.getYear()+'-10';
118 }
119
120 //本季最后年月
121 function showquarterLastMonth()
122 {
123 var Nowdate=new Date();
124 if(Nowdate.getMonth()<3)
125 return Nowdate.getYear()+'-03';
126 else if(Nowdate.getMonth()>2 && Nowdate.getMonth()<6)
127 return Nowdate.getYear()+'-06';
128 else if(Nowdate.getMonth()>5 && Nowdate.getMonth()<9)
129 return Nowdate.getYear()+'-09';
130 else if(Nowdate.getMonth()>8)
131 return Nowdate.getYear()+'-12';
132 }
133
134
135 //本年开始年月
136 function showyearFirstMonth()
137 {
138 var Nowdate=new Date();
139 return Nowdate.getYear()+'-01';
140 }
141
142 //本年最后年月
143 function showyearLastMonth()
144 {
145 var Nowdate=new Date();
146 return Nowdate.getYear()+'-12';
147 }
148 //格式化日期格式
149 function Date.prototype.toString(){
150 return this.getFullYear()+"-"+(this.getMonth()+1)+"-"+this.getDate();
151 }
152 // -->
153 </mce:script>
转自http://blog.csdn.net/cntmi/article/details/4742021