


How to display today's date in real time using javascript_javascript skills
May 16, 2016 pm 03:58 PMThe example in this article describes the method of using javascript to display the current day's date in real time. Share it with everyone for your reference. The specific implementation method is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>js显示时间</title> </head> <body> <div id="divBottom"></div> <script type="text/javascript"> //获取当天日期 function date() { var date=new Date(); var year=date.getFullYear(); var month=date.getMonth()+1; var day=date.getDate(); var hour="00"+date.getHours(); hour=hour.substr(hour.length-2); var minute="00"+date.getMinutes(); minute=minute.substr(minute.length-2); var second="00"+date.getSeconds(); second=second.substr(second.length-2); var week=date.getDay(); switch(week) { case 1:week="星期一 ";break; case 2:week="星期二 ";break; case 3:week="星期三 ";break; case 4:week="星期四 ";break; case 5:week="星期五 ";break; case 6:week="星期六 ";break; case 0:week="星期日 ";break; default:week="";break; } document.getElementById("divBottom").innerHTML=year+"年"+month+"月"+day+"日"+" "+hour+":"+minute+":"+second+" "+week; } setInterval("date()",1000); </script> </body> </html>
The operation effect is as shown below:
I hope this article will be helpful to everyone’s JavaScript programming design.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to search previous Weibo by date on Weibo_How to search previous Weibo by date on Weibo

How to implement an online speech recognition system using WebSocket and JavaScript

How to remove the date that appears automatically when printing from PPT handouts

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems

How to display date and seconds in the top bar of Ubuntu 17.10?

How to implement an online reservation system using WebSocket and JavaScript

How to change the date into a pound sign in Excel

How to use JavaScript and WebSocket to implement a real-time online ordering system
