get last week in javascript

后端 未结 3 807
逝去的感伤
逝去的感伤 2021-01-07 07:41

I am using the following in a script:

var startDate = new Date(\"10/12/2012\");
var endDate = new Date(\"10/18/2012\");

I would like those

3条回答
  •  星月不相逢
    2021-01-07 08:01

    Using date.js to get last Sunday

    Date.today().moveToDayOfWeek(0, -1); // -1 indicates to go back
    

    Best to use a library to manipulate dates. It will make your life a lot easier.

    Having said that have a long-term aim to understand dates in JavaScript. It will help you with things like debugging.

提交回复
热议问题