时间日期小案例

Original 2019-02-21 13:14:31 172
abstract:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><style>.data{width:400px;height:500px;background-color: #A6BBCB;position: absolute;left: 50

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<style>

.data{width:400px;height:500px;background-color: #A6BBCB;position: absolute;left: 50%;top:50%;margin-top:-250px;

margin-left:-200px;box-shadow: 0px 0px 20px #1C1C1C;border-radius: 5px; }

.up{width:93%;height:50px;background-color: rgba(255, 255, 255, 0.3);border-radius: 4px;

margin:5px auto;line-height:50px;padding-left:15px;font-size: 25px;color:#ff6500;font-weight: bolder;}

.down{font-size:80px;color:#ff6500;font-weight: bolder;text-align: center;line-height: 280px;}

.down1{font-size:30px;color:#ff6500;font-weight: bolder;text-align: center;line-height: 50px;}

</style>

<title>日期案例</title>

</head>

<body>

<div class="data">

<div class="up">

今天是地球公元:<span class="up_year" id="up_yea"></span> 年<span  class="up_month" id="ups"></span>月

</div>

<div class="down" id="a"></div>

<div class="down1" id="h"></div>

</div>


<script type="text/javascript">

var yea,mont,dat,h

window.onload=function(){

var today = new Date();

yea=document.getElementById("up_yea")

yea.innerHTML=today.getFullYear();

mont=document.getElementById("ups");

mont.innerHTML=today.getMonth()+1;

dat=document.getElementById("a");

dat.innerHTML=today.getDate()+"日";

h=document.getElementById("h");

h.innerHTML=today.getHours()+"时"+today.getMinutes()+"分"+today.getSeconds()+"秒";

}

</script>

</body>

</html>



Correcting teacher:韦小宝Correction time:2019-02-21 13:17:12
Teacher's summary:js中的时间函数在实际的开发中也是经常会用到的 没事的时候记得要多练习哦!

Release Notes

Popular Entries