[Solved] How to get 12am 7 days ago? [duplicate]


You can go back seven days, then just use Date#setHours() to adjust the time portion:

var date = new Date("2020-12-02T16:53:12.215"); //assume a stable time
//go seven days back
date.setDate(date.getDate() - 7);
//set the time to 12:00:00.000
date.setHours(12, 0, 0 , 0);

console.log(date.toString());        //human-readable
console.log(date.getTime());         //Unix timeastamp in milliseconds
console.log(date.getTime() / 1000);  //regula Unix timeastamp in seconds

6

solved How to get 12am 7 days ago? [duplicate]