Date 与 switch的运用

时间:2022-04-22 21:53:08

<html>
<head>
<title>日期</title>
<script>
function toChinese(day){
switch(day){
case 0:
return "日";
case 1:
return "一";
case 2:
return "二";
case 3:
return "三";
case 4:
return "四";
case 5:
return "五";
case 6:
return "六";

}
}

var oDate=new Date();
var str=oDate.getFullYear()+"年"+(oDate.getMonth()+1)+"月"+oDate.getDate()+"日 星期"+toChinese(oDate.getDay());
alert("现在是:"+str);
</script>
</head>
<body>
</body>
</html>