var time = new Date(); //當前時間 var year = time.getFullYear();//當前年份 var month = time.getMonth()+1; //當前月份 var Same_day = time.getDate(); //當前月份幾號 var t... ...
var time = new Date(); //當前時間 var year = time.getFullYear();//當前年份 var month = time.getMonth()+1; //當前月份 var Same_day = time.getDate(); //當前月份幾號 var time1 = new Date(year,month,1-1); var Last_day = time1.getDate();//當前月份的最後一天 var week = new Date(year,month-1,1).getDay();//獲取當月1號在周幾 time.setMonth(5)//設置月份5代表六月份 console.log(year+"年"+month+"月"+Same_day+"日"+",本月共有"+Last_day+"天"+",周一在星期"+week);