获取年月日时分秒我们用到有函数getDay(),getMonth(),getSeconds(),getFullYear(),getMilliseconds()等函数
获取天数据,
<html>
<body>
<button onclick="var myDate = new Date(); alert(myDate.getDay());">Date: get Day</button>
</body>
</html>
月
<button onclick="var myDate = new Date(); alert(myDate.getMonth());">
Date: get Month
</button>
秒
<button onclick="var myDate = new Date(); alert(myDate.getSeconds());">
Date: get Seconds
</button>
年
<button onclick="var myDate = new Date();
alert(myDate.getFullYear());">
Date: get Full Year</button>
分钟
<button onclick="var myDate = new Date();
alert(myDate.getMilliseconds());">
Date: get Milliseconds</button>
日期精度处理函数
<html>
<head>
<title>the date</title>
<script type = "text/网页特效">
var started = new Date();
var now = started.getTime();
</script>
</head>
<body>
<p id="dateField"></p>
<script type = "text/javascript">
var bottom = new Date();
var diff = (bottom.getTime() - now)/1000;
var finaltime = diff.toPrecision(5);
var dateLoc = document.getElementById("dateField");
dateLoc.innerHTML = "Time: " + finaltime + " seconds.";
</script>
</body>
</html>