11 lines
253 B
JavaScript
11 lines
253 B
JavaScript
function startOfWeek(date)
|
|
{
|
|
var diff = date.getDate() - date.getDay() + (date.getDay() === 0 ? -6 : 1);
|
|
|
|
return new Date(date.setDate(diff));
|
|
|
|
}
|
|
|
|
dt = new Date();
|
|
|
|
console.log(startOfWeek(dt).toString());
|