js 得到当前季度

时间:2016-01-11 16:30:47   收藏:0   阅读:2331
 1 Date.prototype.getQuarter = function() {
 2         var month = this.getMonth();
 3         if(month  < 3) {
 4             return ‘第一季度‘;
 5         }else if(month < 6) {
 6             return ‘第二季度‘;
 7         }else if(month <9) {
 8             return ‘第三季度‘;
 9         }else if(month <12) {
10             return ‘第四季度‘;
11         }
12 };

调用方式:

new Date().getQuarter(); 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!