functiongetWeekInYear(date) { console.log(date) //判断该星期是否跨年,如果跨年就是第一周 letweekStartDate = getWeekStartByDate(date)//一周开始时间 console.log(weekStartDate,'weekStartDate') letendDate = getDateFromDay(weekStartDate, 6)//一周结束时间 console.log(endDate,'endDate') if(weekSt...
js根据日期获得星期 varweekday = getWeekday('2013-9-26');functiongetWeekday(sDate){vardt =newDate(sDate.replace(/-/g, '/'));vara = ['星期日', '星期一','星期二','星期三','星期四','星期五','星期六'];returna[dt.getDay()]; }...
function RetnW() {//JS的数组 var date=new Date(); var day=date.getDay(); var weeks=new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); var week=weeks[day]; return week } function RetnWF2() {//JS判断的if elseif方法 var wstr=""; var ...
functiongetWeekday(year,month,day){ // 创建一个Date对象,注意月份是从0开始的,所以需要减1 vardate=newDate(year,month-1,day); // 使用getDay()方法获取星期,返回的是0-6的数字,0代表星期天 varweekday=date.getDay(); // 创建一个数组来存储星期的中文表示 varweekdays=['星期天','星期一','星...
getWeekStartDate() { var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek); return formatDate(weekStartDate); } //获得本周的结束日期 function getWeekEndDate() { var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek)); return formatDate(weekEndDate...
//第一种方法 var str = ""; var week = new Date().getDay(); if (week == 0) { str = "今天是星期日"; } else if (week == 1) { str = "今天是星期一"; } else if (week == 2) { str = "今天是星期二"; } else if (week == 3) { str = "今天是星期三"; } else ...
functioncountWorkDay(sDay,eDay){vars=stringToDate(sDay),e=stringToDate(eDay);vars_t_w=s.getDay(),e_t_w=e.getDay();//相差天数vardiffDay=(e-s)/(1000*60*60*24)+1;vardiffWeekDay=diffDay-(s_t_w==0?0:7-s_t_w)+e_t_w;//计算有几个完整的周varweeks=Math.floor(diffWeekDay...
function getWeekStartDate() { var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek); return formatDate(weekStartDate); } //获得本周的停止日期 function getWeekEndDate() { var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek)); return formatDate(...
var day = date.getDate(); let da = year + "-" + month + "-" + day let data = month + "月" + day + '日' var weekArray = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); ...
('2019-12-30')* // => 1* date2Week('2019-12-29')* // => 52* date2Week('2019-01-01')* // => 1* date2Week('2019-01-07')* // => 2* @param {string?} str 时间字符串* @return {number} 周数*/function date2Week(str) { // 获取date,不传则默认为当前date,这里没有...