//string转为Date var date = new Date("2017-12-01"); //Date转string var year = date.getFullYear(); //年 var month = date.getMonth() + 1; //月 var day = date.getDate(); //周 var weekday = date.getDay(); //周几 var hour = date.getHours(); //时,默认为8 var minute = date.getMinutes(); //分,默认为0 var second = date.getSeconds(); //秒, 默认为0 //函数 function getDateString(date) { var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); if (month < 10) { month = "0" + month; } if (day < 10) { day = "0" + day; } return year + "-" + month + "-" + day; } //日期计算 var days = 44; date.setDate(date.getDate() + days);