Home JS将字符串转为日期
Post
Cancel

JS将字符串转为日期

1
2
3
4
5
6
7
var str = "2010-08-01";
// 转换日期格式,"2010/08/01"
str = str.replace(/-/g, '/');
// 创建日期对象
var date = new Date(str);
// 加一天
date.setDate(date.getDate() + 1);
This post is licensed under CC BY 4.0 by the author.