我这个存在什么问题吗
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>改变日期格式</title> </head> <body> <script> function newDate(){ var today=new Date(), year=today.getFullYear(), month=today.getMonth()+1, date=today.getDate(), hours=today.getHours(), minutes=today.getMinutes(), seconds=today.getSeconds(), weeks=["日","一","二","三","四","五","六"]; document.wirte("今天是"+year+"年"+month+"月"+date+"日"+"weeks[week]"+"<br>"+hours+":"+minutes+":"+scconds); } var dateformat=new Date(); document.write(dateformat); </script> </body> </html>
0
收起
正在回答
2回答
同学的代码运行结果为:
与习题要求不相符,建议参考:
希望可以帮到你!
宇航员_
2019-05-24 15:02:51
function newDate(){
var today=new Date();
var year=today.getFullYear();
var month=today.getMonth()+1;
var date=today.getDate();
var hours=today.getHours();
var minutes=today.getMinutes();
var seconds=today.getSeconds();
var weeks=["日","一","二","三","四","五","六"];
document.write("今天是"+year+"年"+month+"月"+date+"日"+'星期'+weeks[today.getDay()]+"<br>"+hours+":"+minutes+":"+seconds);
}
newDate();//你没调用你的方法
变量要用var定义
语句结束用(;)号不是逗号(,)
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星