html page embedded date and time

Give a script:

<script type="text/javascript">
function getNowDate() {
var date = new Date();
var year = date.getFullYear() //
var month = date.getMonth() + 1; //
var day  = date.getDate(); //
var hour = date.getHours(); //
var minutes = date.getMinutes(); //
varseconds The = date.getSeconds () // seconds 
var weekArr = [ ' Sunday ' , ' Monday ' , ' Tuesday ' , ' Wednesday ' , ' Thursday ' , ' Friday ' , ' Saturday ' ];
 var Week = weekArr [DATE .getDay ()];
 // to the front of the data plus a number of "0" 
IF (month The > =  . 1  && month The <=  . 9 ) {
 month = "0" + month;
}
if (day >= 0 && day <= 9) {
 day = "0" + day;
}
if (hour >= 0 && hour <= 9) {
 hour = "0" + hour;
}
if (minutes >= 0 && minutes <= 9) {
 minutes = "0" + minutes;
}
if (seconds >= 0 && seconds <= 9) {
 seconds = "0" + seconds;
}
document.getElementById("info").innerHTML = year + "" + month + "" + day + "" + " " + week;
//return currentdate;
}

</script>

Then find the location corresponding to the added time

<div class="fl">
<span id="info"></span>
</div>

Finally, the page load time he began to read:

<body οnlοad="getNowDate()">

Original link: https: //blog.csdn.net/copyerman115/article/details/78584715

 

Guess you like

Origin www.cnblogs.com/fuyuteng/p/12363641.html