[英]Javascript “end of week” date calculations?
是否有一个帮助程序库用于执行这些类型的日期计算,如在Rails中?
Date.today.end_of_week
功能没有内置,但您可以定义自己的:
Date.prototype.endOfWeek = function(){
return new Date(
this.getFullYear(),
this.getMonth(),
this.getDate() + 6 - this.getDay()
);
};
var now = new Date();
// returns next saturday; and returns saturday if it is saturday today.
console.log( now.endOfWeek() );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.