博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
获取第几周
阅读量:6822 次
发布时间:2019-06-26

本文共 1320 字,大约阅读时间需要 4 分钟。

getDateParam:function (date) {                var nowDate =new Date(date.slice(0,10));//截取日期字符串转换问日期变量                var theWeek = nowDate.getDay(); //当天为周几                var daysOfMonth = nowDate.getDate(); //这个月的第几天                var monthOfYear = nowDate.getMonth()+1; //今年的几月份                var theYear = nowDate.getFullYear(); //年                var weekOfMonth = "";   //这个月的第几周                var arr = ["日","一","二","三","四","五","六"];                if(theWeek == 0){     //这天刚好是周日                    weekOfMonth = Math.ceil(daysOfMonth/7);                }else {                    weekOfMonth = Math.ceil((daysOfMonth + 7 - theWeek)/7);                }                var theWeekStr = theWeek+"";                theWeekStr ="周" + theWeekStr.replace(new RegExp(theWeekStr, "g"),arr[theWeek]);                var dateParameter = {                    "theWeekStr":theWeekStr,        //周几                    "monthOfYear":monthOfYear<10 ? "0"+monthOfYear : monthOfYear,                    "weekOfMonth":weekOfMonth+"",                    "theYear":theYear+"",                    "daysOfMonth":daysOfMonth<10 ? "0"+daysOfMonth : daysOfMonth,                    "createDate":date.slice(0,10),                }                return dateParameter;            }

 

转载于:https://www.cnblogs.com/longsiyuan/p/6927461.html

你可能感兴趣的文章