Date
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
var d = new Date();
function dateTostring(d) {
var str = "";
var y = d.getFullYear();
var m = d.getMonth()+1;
var _d = d.getDate();
var h = toTwo(d.getHours());
var mi = toTwo(d.getMinutes());
var s = toTwo(d.getSeconds());
var weekday = d.getDay();
var arr = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
str += y + "年" + m + "月" + _d + "日 ";
str += h + ":" + mi + ":" + s + " " + arr[weekday];
return str;
}
function toTwo(v) {
return v<10?"0"+v:v;
}
console.log(dateTostring(d));
var str = "2020-1-12";
var date = new Date(str);
var date2 = new Date(Date.parse(str));
console.log(date2.getDate());
console.log(Date.parse(str));
</script>
</body>
</html>