<html>
<head>
    <title>JavaScript获取当前日期</title>
    <script>
        // 定义函数获取当前日期
        function getCurrentDate() {
            var date = new Date();
            return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
        }
    </script>
</head>
<body>
    <p>当前日期:<span id='date'></span></p>
    <script>
        // 获取当前日期并填充到页面
        document.getElementById('date').innerHTML = getCurrentDate();
    </script>
</body>
</html>

原文地址: https://www.cveoy.top/t/topic/llkZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录