Showing
1 changed file
with
14 additions
and
116 deletions
@@ -23,7 +23,7 @@ var g = new common.grid({ | @@ -23,7 +23,7 @@ var g = new common.grid({ | ||
23 | {display:"订单号",name:"orderCode"}, | 23 | {display:"订单号",name:"orderCode"}, |
24 | {display:"优惠券名称",name:"couponName"}, | 24 | {display:"优惠券名称",name:"couponName"}, |
25 | {display:"有效期", render: function(item) { | 25 | {display:"有效期", render: function(item) { |
26 | - return '<p>' + date_fuction('Y-m-d H:i:s', item.startTime) + '--' + item.endTimeStr + '</p>'; | 26 | + return '<p>' + date_fuction(item.startTime) + '--' + item.endTimeStr + '</p>'; |
27 | }}, | 27 | }}, |
28 | {display:"状态",render: function(item) { | 28 | {display:"状态",render: function(item) { |
29 | var status = ""; | 29 | var status = ""; |
@@ -122,120 +122,18 @@ $(document).on("keyup", ".number", function () { | @@ -122,120 +122,18 @@ $(document).on("keyup", ".number", function () { | ||
122 | }); | 122 | }); |
123 | 123 | ||
124 | 124 | ||
125 | -function date_fuction(format, timestamp){ | ||
126 | - var a, jsdate=((timestamp) ? new Date(timestamp*1000) : new Date()); | ||
127 | - var pad = function(n, c){ | ||
128 | - if((n = n + "").length < c){ | ||
129 | - return new Array(++c - n.length).join("0") + n; | ||
130 | - } else { | ||
131 | - return n; | ||
132 | - } | ||
133 | - }; | ||
134 | - var txt_weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; | ||
135 | - var txt_ordin = {1:"st", 2:"nd", 3:"rd", 21:"st", 22:"nd", 23:"rd", 31:"st"}; | ||
136 | - var txt_months = ["", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; | ||
137 | - var f = { | ||
138 | - // Day | ||
139 | - d: function(){return pad(f.j(), 2)}, | ||
140 | - D: function(){return f.l().substr(0,3)}, | ||
141 | - j: function(){return jsdate.getDate()}, | ||
142 | - l: function(){return txt_weekdays[f.w()]}, | ||
143 | - N: function(){return f.w() + 1}, | ||
144 | - S: function(){return txt_ordin[f.j()] ? txt_ordin[f.j()] : 'th'}, | ||
145 | - w: function(){return jsdate.getDay()}, | ||
146 | - z: function(){return (jsdate - new Date(jsdate.getFullYear() + "/1/1")) / 864e5 >> 0}, | ||
147 | - | ||
148 | - // Week | ||
149 | - W: function(){ | ||
150 | - var a = f.z(), b = 364 + f.L() - a; | ||
151 | - var nd2, nd = (new Date(jsdate.getFullYear() + "/1/1").getDay() || 7) - 1; | ||
152 | - if(b <= 2 && ((jsdate.getDay() || 7) - 1) <= 2 - b){ | ||
153 | - return 1; | ||
154 | - } else{ | ||
155 | - if(a <= 2 && nd >= 4 && a >= (6 - nd)){ | ||
156 | - nd2 = new Date(jsdate.getFullYear() - 1 + "/12/31"); | ||
157 | - return date("W", Math.round(nd2.getTime()/1000)); | ||
158 | - } else{ | ||
159 | - return (1 + (nd <= 3 ? ((a + nd) / 7) : (a - (7 - nd)) / 7) >> 0); | ||
160 | - } | ||
161 | - } | ||
162 | - }, | ||
163 | - | ||
164 | - // Month | ||
165 | - F: function(){return txt_months[f.n()]}, | ||
166 | - m: function(){return pad(f.n(), 2)}, | ||
167 | - M: function(){return f.F().substr(0,3)}, | ||
168 | - n: function(){return jsdate.getMonth() + 1}, | ||
169 | - t: function(){ | ||
170 | - var n; | ||
171 | - if( (n = jsdate.getMonth() + 1) == 2 ){ | ||
172 | - return 28 + f.L(); | ||
173 | - } else{ | ||
174 | - if( n & 1 && n < 8 || !(n & 1) && n > 7 ){ | ||
175 | - return 31; | ||
176 | - } else{ | ||
177 | - return 30; | ||
178 | - } | ||
179 | - } | ||
180 | - }, | ||
181 | 125 | ||
182 | - // Year | ||
183 | - L: function(){var y = f.Y();return (!(y & 3) && (y % 1e2 || !(y % 4e2))) ? 1 : 0}, | ||
184 | - //o not supported yet | ||
185 | - Y: function(){return jsdate.getFullYear()}, | ||
186 | - y: function(){return (jsdate.getFullYear() + "").slice(2)}, | ||
187 | - | ||
188 | - // Time | ||
189 | - a: function(){return jsdate.getHours() > 11 ? "pm" : "am"}, | ||
190 | - A: function(){return f.a().toUpperCase()}, | ||
191 | - B: function(){ | ||
192 | - // peter paul koch: | ||
193 | - var off = (jsdate.getTimezoneOffset() + 60)*60; | ||
194 | - var theSeconds = (jsdate.getHours() * 3600) + (jsdate.getMinutes() * 60) + jsdate.getSeconds() + off; | ||
195 | - var beat = Math.floor(theSeconds/86.4); | ||
196 | - if (beat > 1000) beat -= 1000; | ||
197 | - if (beat < 0) beat += 1000; | ||
198 | - if ((String(beat)).length == 1) beat = "00"+beat; | ||
199 | - if ((String(beat)).length == 2) beat = "0"+beat; | ||
200 | - return beat; | ||
201 | - }, | ||
202 | - g: function(){return jsdate.getHours() % 12 || 12}, | ||
203 | - G: function(){return jsdate.getHours()}, | ||
204 | - h: function(){return pad(f.g(), 2)}, | ||
205 | - H: function(){return pad(jsdate.getHours(), 2)}, | ||
206 | - i: function(){return pad(jsdate.getMinutes(), 2)}, | ||
207 | - s: function(){return pad(jsdate.getSeconds(), 2)}, | ||
208 | - //u not supported yet | ||
209 | - | ||
210 | - // Timezone | ||
211 | - //e not supported yet | ||
212 | - //I not supported yet | ||
213 | - O: function(){ | ||
214 | - var t = pad(Math.abs(jsdate.getTimezoneOffset()/60*100), 4); | ||
215 | - if (jsdate.getTimezoneOffset() > 0) t = "-" + t; else t = "+" + t; | ||
216 | - return t; | ||
217 | - }, | ||
218 | - P: function(){var O = f.O();return (O.substr(0, 3) + ":" + O.substr(3, 2))}, | ||
219 | - //T not supported yet | ||
220 | - //Z not supported yet | ||
221 | - | ||
222 | - // Full Date/Time | ||
223 | - c: function(){return f.Y() + "-" + f.m() + "-" + f.d() + "T" + f.h() + ":" + f.i() + ":" + f.s() + f.P()}, | ||
224 | - //r not supported yet | ||
225 | - U: function(){return Math.round(jsdate.getTime()/1000)} | ||
226 | - }; | ||
227 | - | ||
228 | - return format.replace(/[\]?([a-zA-Z])/g, function(t, s){ | ||
229 | - if( t!=s ){ | ||
230 | - // escaped | ||
231 | - ret = s; | ||
232 | - } else if( f[s] ){ | ||
233 | - // a date function exists | ||
234 | - ret = f[s](); | ||
235 | - } else{ | ||
236 | - // nothing special | ||
237 | - ret = s; | ||
238 | - } | ||
239 | - return ret; | ||
240 | - }); | 126 | +function date_fuction(shijianchuo) |
127 | +{ | ||
128 | + //shijianchuo是整数,否则要parseInt转换 | ||
129 | + var time = new Date(shijianchuo * 1000); | ||
130 | + var y = time.getFullYear(); | ||
131 | + var m = time.getMonth()+1; | ||
132 | + var d = time.getDate(); | ||
133 | + var h = time.getHours(); | ||
134 | + var mm = time.getMinutes(); | ||
135 | + var s = time.getSeconds(); | ||
136 | + return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s); | ||
241 | } | 137 | } |
138 | + | ||
139 | +function add0(m){return m<10?'0'+m:m } |
-
Please register or login to post a comment