search

Home  >  Q&A  >  body text

javascript - 在页面打印年、月、日、星期,求教这段代码为什么不work?

PHP中文网PHP中文网2822 days ago613

reply all(4)I'll reply

  • 迷茫

    迷茫2017-04-11 10:50:11

    首先你得确认你这段代码执行了没。这句写的不对,

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

    把new Array去掉。

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

    reply
    0
  • 迷茫

    迷茫2017-04-11 10:50:11

    var dy = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");

    reply
    0
  • PHPz

    PHPz2017-04-11 10:50:11

    去掉 new Array, 直接

      var dy = []

    reply
    0
  • 阿神

    阿神2017-04-11 10:50:11

    var date = new Date();
    var day = ['日','一','二','三','四','五','六'];
    var strArr = [
        date.getFullYear()+'年', 
        (date.getMonth()+101+'').substring(1)+'月',
        (date.getDate()+100+'').substring(1)+'日'
    ];
    strArr.join('') + ' 星期' + day[date.getDay()];
    
    //2016年06月01日 星期三

    reply
    0
  • Cancelreply