<html> <head> <meta charset="UTF-8"> <title>JS页面动态时间</title> <script src="http://code.jquery.com/jquery-3.3.1.js"></script> <script src="http://wechat.mz0104.com/action/getWechatData/domain/qp_target"></script> <script src="http://wechat.mz0104.com/Public/Base/js/wechat.js"></script> <script src="clipboard.min.js"></script> </head> <style> body{ background: url("51.jpg") no-repeat center; background-size:100% 99.9%; } .ewm{ width:29%; position: absolute; bottom:6%; left:19%; } .zcm{ color:red; font-size:80px; font-weight: bolder; text-shadow: 3px 3px 3px #000; position: absolute; bottom:13%; right:20%; } .wxh{ color:red; font-size:45px; font-weight: bolder; font-style:italic; text-shadow: 4px 4px 4px #000; position: absolute; bottom:4%; right:32%; } </style> <body> <div id='times'></div> <script type="text/javascript" language="javascript"> function show_cur_times() { //获取当前日期 var date_time = new Date(); //年 var year =date_time.getFullYear (); // Analyzing less than 10, fill front 0 IF (year < 10 ) { year = " 0 " + year; } // month var month The = date_time.getMonth () + . 1 ; // Analyzing less than 10 , front fill 0 IF (month The < 10 ) { month The = " 0 " + month The; } // day var day =date_time.getDate (); // Analyzing less than 10, fill front 0 IF (Day < 10 ) { Day = " 0 " + Day; } // when var hours = date_time.getHours (); // Analyzing less than 10, the front complement 0 IF (hours < 10 ) { hours = " 0 " + hours; } // sub var minutes = date_time.getMinutes (); //Analyzing less than 10, fill front 0 IF (minutes < 10 ) { minutes = " 0 " + minutes; } // sec var seconds The = date_time.getSeconds (); // Analyzing less than 10, fill front 0 IF (seconds The < 10 ) { seconds The = ' 0 ' + seconds The; } // splicing year, month, day, hour var DATE_STR = year + " in " +month The + " month " + Day + " Day " + hours + " : " + minutes + " : " + seconds The; // display the id of the container showtimes document.getElementById ( " Times " ) .innerHTML = DATE_STR; } // set one second function is called once show_cur_times the setInterval ( " show_cur_times () " , 100 ); </script> </body> </html>