Date对象

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Date对象</title>
</head>
<body>
    <script>
        //构建对象
        var date = new Date()
        //获取年份
        var fullyear = date.getFullYear();
        document.write(fullyear)
        document.write("<br/>")
        //获取月份(取值范围为0~11)
        var month = date.getMonth();
        month = month + 1
        document.write(month)
        document.write("<br/>")
        //取这个月的几号
        var dayofmonth = date.getDate()
        /*   getDay();
           getHours();
           getSeconds();
           getMilliseconds();*/
        document.write(dayofmonth)
    </script>
</body></html>
posted @ 2019-04-21 22:11  木易#  阅读(45)  评论(0编辑  收藏  举报