JavaScript&Date对象

时间:2022-09-18 11:21:07

JavaScript Date对象

 <script type="text/javascript">
var date = new Date(); document.write("输出变量date,输出当前时间" + date + "<br/>" + "<br/>");
document.write("getDate()方法,获取日期" + date.getDate() + "<br/>" + "<br/>");
document.write("getFullYear()方法,获取年份(四位数表示)" + date.getFullYear() + "<br/>" + "<br/>");
document.write("getYear()方法,获取年份" + date.getYear() + "<br/>" + "<br/>");
document.write("getMonth()方法,获取月份" + date.getMonth() + "<br/>" + "<br/>");
document.write("getHours()方法,获取小时(24小时制)" + date.getHours() + "<br/>" + "<br/>");
document.write("getMinutes()方法,获取分钟数" +date.getMinutes() + "<br/>" + "<br/>");
document.write("getSeconds()方法,获取秒钟数" + date.getSeconds() + "<br/>" + "<br/>");
document.write("getTime()方法,获取时间" + date.getTime() + "<br/>" + "<br/>"); </script>

JavaScript&Date对象