您的位置:首页 > Web前端 > JavaScript

JS 获取时间

2015-10-30 11:00 597 查看
//获取当前月的第一天

function getFirstDayInCurrtMonth() {

var date = new Date()

with (date) {

year = date.getYear() + 1900;

month = date.getMonth() + 1;

}

return year + "-" + month + "-1" + " 00:00:00";

}

//获取下个月的第一天

function getFirstDayInNextMonth() {

var date = new Date()

with (date) {

year = date.getYear() + 1900;

month = date.getMonth() + 2;

}

return year + "-" + month + "-1" + " 00:00:00";

}

//获取当前月的最后一天

function getLastDayInCurrMonth() {

var date = new Date()

with (date) {

year = date.getYear() + 1900;

month = date.getMonth() + 1;

}

var day = new Date(year, month, 0);

return year + '-' + month + '-' + day.getDate() + " 23:59:59";//获取当月最后一天日期

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: