解决方法
试试这个:
var year = 2012; var week = 2; var d = new Date("Jan 01," + year + " 01:00:00"); var w = d.getTime() + 604800000 * (week - 1); var n1 = new Date(w); var n2 = new Date(w + 518400000) console.log(n1); console.log(n2);
n1包含一周的第一天
n2包含一周的最后一天
至于常数:604800000是一周,以毫秒为单位518400000是六天