简单教程
提交运行
代码编辑器:
<p id="demo">单击按钮显示给定时间的年份(UTC)</p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ var d = new Date("July 21, 1983 01:15:00"); var x = document.getElementById("demo"); x.innerHTML=d.getUTCFullYear(); } </script>
运行结果: