js 里怎么将字符串变成date

如题所述

var str = "2010-08-01";
// 转换日期格式
str = str.replace(/-/g, '/'); // "2010/08/01";
// 创建日期对象
var date = new Date(str);
// 加一天
date.setDate(date.getDate() + 1);
温馨提示:答案为网友推荐,仅供参考