标签:style class blog code java http
原文:javaScript Code 用javascript确定每月第二个星期五
废话少说只就上Code:
var SecondFriday = { getSecondFriday: function () { var flag = 0; //(1) 获取当月月初时间,时间格式为:Sun Jun 01 2014 00:00:00 GMT+0800 (中国标准时间) var thisDate = new Date(new Date().getFullYear(), new Date().getMonth()); for (var i = 0; i < 15; i++) { //(2) 因为是每个月的第二个星期五,所以循环15次以内就可以 wd = thisDate.getDay();//(3)判定当月月初是星期几 if(wd===0){//(4)特殊处理星期天。 因为星期天为‘0’。 console.log(‘here‘); return thisDate.getFullYear() + "-" + (thisDate.getMonth() + 1) + "-" +"13" } if ((i + wd) % 5 == 0) { flag = flag + 1;//(5)标示符,确定是第二个星期五 if (flag == 2) { return thisDate.getFullYear() + "-" + (thisDate.getMonth() + 1) + "-" + (i + wd) } } } } };
//Chrom 测试
console.log(SecondFriday.getSecondFriday());
javaScript Code 用javascript确定每月第二个星期五,布布扣,bubuko.com
javaScript Code 用javascript确定每月第二个星期五
标签:style class blog code java http
原文地址:http://www.cnblogs.com/lonelyxmas/p/3781544.html