23.htm

来自「介绍了javascript的常用的函数」· HTM 代码 · 共 38 行

HTM
38
字号
<html>
<head>
<title>全中文日期显示</title>
</head>
<body>
<script language="javascript">
<!--
	str = new Array("零","一","二","三","四","五","六","七","八","九");
	function number(num){
		tostr = "" + num;
		if(num < 10 ){
			return str[num];
		}else if(num == 10){
			return "十";
		}else if(num < 20){
			return "十" + str[tostr.charAt(1)];
		}else if(num == 20){
			return "二十";
		}else if(num <30){
			return "二十" + str[tostr.charAt(1)];
		}else if(num == 30){
			return "三十";
		}else if(num > 30){
			return "三十" + str[tostr.charAt(1)];
		}
	}
	
	d = new Date();
	year  = ""+d.getYear();
	month = d.getMonth() + 1;
	date  = d.getDate();
	document.write(str[year.charAt(0)]+str[year.charAt(1)]+
				   str[year.charAt(2)]+str[year.charAt(3)]+"年");
	document.write(number(month)+"月"+number(date)+"日");
//-->
</script>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?