JavaScript&Date对象
JavaScript Date对象
1 <script type="text/javascript"> 2 var date = new Date(); 3 4 document.write("输出变量date,输出当前时间" + date + "<br/>" + "<br/>"); 5 document.write("getDate()方法,获取日期" + date.getDate() + "<br/>" + "<br/>"); 6 document.write("getFullYear()方法,获取年份(四位数表示)" + date.getFullYear() + "<br/>" + "<br/>"); 7 document.write("getYear()方法,获取年份" + date.getYear() + "<br/>" + "<br/>"); 8 document.write("getMonth()方法,获取月份" + date.getMonth() + "<br/>" + "<br/>"); 9 document.write("getHours()方法,获取小时(24小时制)" + date.getHours() + "<br/>" + "<br/>"); 10 document.write("getMinutes()方法,获取分钟数" +date.getMinutes() + "<br/>" + "<br/>"); 11 document.write("getSeconds()方法,获取秒钟数" + date.getSeconds() + "<br/>" + "<br/>"); 12 document.write("getTime()方法,获取时间" + date.getTime() + "<br/>" + "<br/>"); 13 14 </script>