The specific code of JavaScript date effects is for your reference. The specific content is as follows Directly on the code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css"> *{ padding: 0; margin: 0; } #date{ width: 450px; height: 300px; background-color: darkorange; border-radius: 10px; margin: 100px auto; } #nowDate{ width: 450px; height: 60px; line-height: 60px; text-align: center; color: #fff; font-size: 26px; } #day{ width: 200px; height: 200px; line-height: 200px; background-color: orchid; margin: 0 auto; text-align: center; } </style> </head> <body> <div id="date"> <p id="nowDate"></p> <p id="day"></p> </div> <script type="text/javascript"> // Get the tag var nowDate = document.getElementById("nowDate"); var day = document.getElementById("day"); // Use timer to update time changes setInterval(nowNumTime,1000); nowNumTime(); function nowNumTime(){ var now = new Date(); var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); var temp = '' + (hour>12 ? hour-12:hour); var year = now.getFullYear(); var month = now.getMonth(); var d = now.getDate(); var week = now.getDay(); console.log(week); //Index var weeks = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; // console.log(temp); if (hour === 0){ temp = '12'; } temp = temp + (minute <10 ? ':0':":"+minute); temp = temp + (second <10 ? ':0':":"+second); temp = temp + (hour>=12 ? ' PM':' AM'); temp = `${year}${month}${d}${temp}${weeks[week]}`; // console.log(temp); nowDate.innerHTML = temp; } </script> </body> </html> Implementation effect diagram: The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: The meaning and usage of linux cd
>>: How to Clear Disk Space on CentOS 6 or CentOS 7
Table of contents 1. Table self-sorting 2. Paging...
Copy code The code is as follows: <!DOCTYPE ht...
The significance of writing order Reduce browser ...
This is an official screenshot. After MySQL 5.7 i...
This article example shares the specific code for...
The table caption can be placed above or below th...
Table of contents linux 1. What is SWAP 2. What d...
Preface The project has requirements for charts, ...
SQL is the main trunk. Why do I understand it thi...
1. Download, install and activate CLion Just foll...
This article mainly introduces the breadcrumb fun...
Everyone knows that data in MySQL needs to be wri...
How to install MySQL 5.7 in Ubuntu 16.04? Install...
Table of contents Preface Computed properties Int...
Recently I want to use goaccess to analyze nginx ...