Posted in Javascript onJune 27, 2013
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function bodyLoad(){ var dateTime=new Date(); var hh=dateTime.getHours(); if(hh<10) hh = '0' + hh; var mm=dateTime.getMinutes(); if(mm<10) mm = '0' + mm; var ss=dateTime.getSeconds(); if(ss<10) ss = '0' + ss; var yy=dateTime.getFullYear(); var MM=dateTime.getMonth()+1; //因为1月这个方法返回为0,所以加1 var dd=dateTime.getDate(); var week=dateTime.getDay(); var days=[ "日 ", "一 ", "二 ", "三 ", "四 ", "五 ", "六 ",] document.getElementById("date").value=yy+"年"+MM+"月"+dd+"日 "+"星期"+days[week] ; document.getElementById("time").value=hh+":"+mm+":"+ss; setTimeout(bodyLoad,1000); } </script> </head> <body onload="bodyLoad()"> <input type="text" id="date" style="border:0 none;" /><input type="text" id="time" style="border:0 none;" /> </body> </html>
js获取当前日期代码适用于网页头部
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@