计算月初和月末的js

function getLast(cur){ //cur 当前时间
var firstDay = new Date(cur.getFullYear() + '/' + (cur.getMonth()+1) + '/' + cur.getDate() + ' 00:00:00');
firstDay.setDate(1);
//月末
var lastDay = new Date(+firstDay);
lastDay.setMonth(lastDay.getMonth() + 1);
lastDay.setDate(0);

return [firstDay,lastDay];
}

 

posted @ 2017-12-29 14:37  糖糖部落  阅读(1147)  评论(0编辑  收藏  举报