JavaScript获取当前日期

<html>
    <head>
        <title>日期</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript">
            var nowTime = new Date();
            //获取日期的年月日
            var c = ":";
            var year = nowTime.getYear();
            var month = nowTime.getMonth();
            var date = nowTime.getDate();
            var hours = nowTime.getHours();
            var minute = nowTime.getMinutes();
            var seconds = nowTime.getSeconds();
            var s = "当前本地时间:";
            s = year+c+month+c+date+" "+hours+c+minute+c+seconds;
            debugger;
        </script>
    </head>
    <body>
    </body>
</html>

 

posted @ 2016-08-01 20:44  sailor4518  阅读(297)  评论(0)    收藏  举报