📜  javascript 获取上周一的日期 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:50.312000             🧑  作者: Mango

代码示例1
let prevMonday = new Date();
prevMonday = new Date(prevMonday.setDate(prevMonday.getDate() - (prevMonday.getDay() + 6) % 7));
// sets the date object to last Monday, if the current day is Monday,
// set it to the current date

prevMonday = new Date(prevMonday.setHours(0,0,0)); // sets hours, mins, secs to 0