Return week start (Monday) based on current day

Viewed 36

The below code returns sunday instead of monday for week start- can someone please help me troubleshoot

function myFunction() {
 var curr = new Date();
  
var first = (curr.getDate() - curr.getDay()) ;
  
var Monday = Utilities.formatDate(new Date(curr.setDate(first)), "UTC", "YYYY-MM-dd");
  
var sh = SpreadsheetApp.getActiveSheet();
  
 sh.getRange("F4").setValue(Monday) ;

}
0 Answers
Related