首页 > Web开发 > 详细

Html简单获取星期

时间:2021-06-04 18:07:00      阅读:23      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h1 id ="date_time"></h1>
		<script type="text/javascript">
			function getWeek(){
				// case 0:
				// return "星期日";
				// case 1:
				// return "星期一;
				// case 2:
				// return "星期二";
				// case 3:
				// return "星期三";
				// case 4:
				// return "星期四";
				// case 5:
				// return "星期五";
				// case 6:
				// return "星期六";
				var week ="日一二三四五六".charAt(Option);
				return"星期"+week;
			}
		function showTime(){
			var dateTime = new Date();
			var year = dateTime.getFullYear();
			var month = dateTime.getMonth()+1;
			month=month<10?"0"+month:month;
			var date = dateTime.getDate();
			date = date<10?"0"+date:date;
			var hour = dateTime.getHours();
			hour = dateTime.getHours();
			hour =hour<10?"0"+hour:hour;
			var minute = dateTime.getMinutes();
			minute = minute<10?"0"+minute:minute;
			var second = dateTime.getSeconds();
			second =second<10?"0"+second:second;
			var day=dateTime.getDay();
			var week =getWeek(day);
			dateTime = year+"年"+month+"月"+date+"日"+" "+week+" "+hour+":"+minute+":"+second;
			document.getElementById("date_time").innerHTML=dateTime;
		}
		
		showTime();
		setInterval("showTime()",1000)
		</script>
	</body>
</html>

Html简单获取星期

原文:https://www.cnblogs.com/imetal/p/14849372.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!