javascript - 在页面打印年、月、日、星期,求教这段代码为什么不work?
PHP中文网
PHP中文网 2017-04-11 10:48:11
0
4
608
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
迷茫

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

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

把new Array去掉。

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

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

PHPzhong

去掉 new Array, 直接

  var dy = []
阿神
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日 星期三
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template