2010-11-22 307 views

回答

10

有一个在功能上没有身材,但你可以定义自己:

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()); 
3

是。 DateJS

我不知道你认为是“周的结束”,假设它是星期六,我相信

Date.parse('saturday'); 

(今天或者,如果今天是星期六)会给你下周六

1

我建立了一个有一定时间t的库这些方法,time.js

它不具备所有的东西DateJS有,可以是好的和坏取决于你如何看待它;)

如果我能我会重现采取任何必要的日期代码实例到本周结束,但有一点涉及。不过,通过查看the code应该很容易找出基础知识。

+0

+1为您的优秀图书馆提供参考,小巧,使用简单,并且只有日常工作的必需品。 – Maks 2012-05-19 03:58:40

相关问题