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

大佬帮我看看,时间不对咋回事·c·

  var s=new Date();

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

  document.write("今天是"+s.getFullYear()+"年"+s.getMonth()+"月"+s.getDay()+"日,"+n[s.getDay()]);


提问者:慕婉清3029059 2022-11-04 10:56

个回答

  • qq_慕慕7457505
    2022-11-07 14:20:50

    js中getMonth()获取的月份是0-11,所以加一就对了

    (s.getMonth() + 1) + "月" +

    “日”是s.getDate(),你写错了