File size: 643 Bytes
08aee07 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Date对象</title>
</head>
<body>
<script>
/*
4. Date:日期对象
1. 创建:
var date = new Date();
2. 方法:
toLocaleString():返回当前date对象对应的时间本地字符串格式
getTime():获取毫秒值。返回当前如期对象描述的时间到1970年1月1日零点的毫秒值差
*/
var date = new Date();
document.write(date + "<br/>");
var str = date.toLocaleString();
document.write(str + "<br/>");
var time = date.getTime();
document.write(time + "<br/>");
</script>
</body>
</html> |