问答详情
源自:7-23 编程练习

如何将默认时间显示改成XXXX年XX月XX日?可以按照真实时间自动抓取的

”Mon Mar 21 2016 13:33:36 GMT+0800 (中国标准时间)“如何修改?

提问者:贪心xiong 2016-03-21 13:36

个回答

  • 小苹果615
    2016-03-21 14:23:16
    已采纳

    <!DOCTYPE  HTML>

    <html >

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>系好安全带,准备启航</title>

    <script type="text/javascript">

        var mydate= new Date();

        var weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];

        var mynum=mydate.getDay();

        var myyear= mydate.getFullYear();

        var mymonth= mydate.getMonth()+1;

        var myday= mydate.getDate();

        document.write(myyear + "年" + mymonth + "月" + myday + "日 " + weekday[mynum] + "<br>");

    </script>

    </head>

    <body>

    </body>

    </html>