用js显示系统当前日期
Posted 旺旺a
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用js显示系统当前日期相关的知识,希望对你有一定的参考价值。
<!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显示系统当前日期的主要内容,如果未能解决你的问题,请参考以下文章