用js顯示系統當前日期
阿新 • • 發佈:2019-02-03
bubuko script eight .get ear -c javascrip pan minute
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>獲取當前的時間</title> </head> <style> #adata{ height: 30px; width: 330px; border: brown 3px solid; } </style> <body> <div id="adata"></div> </body> </html> <script language="JavaScript" type="text/javascript"> window.onload = function() { window.setInterval("Systime(adata)", 1000); } function Systime(adata) { var now = new Date();var year = now.getFullYear(); var month = now.getMonth(); var data = now.getDate(); var day = now.getDay(); var hour = now.getHours(); var minu = now.getMinutes(); var sec = now.getSeconds(); month = month + 1; var arr_week = new Array("星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"); var week = arr_week[day]; var time = year + "年 " + month + "月 " + data + "日 " + week + " " + hour + ":" + minu + ":" + sec; adata.innerHTML = "當前時間: " + time; } </script>
用js顯示系統當前日期