Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript get date of last monday

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #date #monday
ADD COMMENT
Topic
Name
7+7 =