且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取具有特定时间的Date()对象

更新时间:2023-10-05 16:16:10

您可以使用以下方法将日期设置为一周的开始:

You can set the date to the start of the week with this:

var d = new Date();
d.setDate(d.getDate() - d.getDay());

然后使用 .setHours(0) .setMinutes(0)等来清除时间.

Then use .setHours(0), .setMinutes(0), etc. to clear out the time.