本文目录一览:
关于JavaScript显示时间的一段简单代码!
html
body
script language="JavaScript" type="text/JavaScript"
!--
var isnMonth = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");
var isnDay = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");
today = new Date () ;
if(document.all){
document.write("font color=\"#27C28D\"\n");
document.write(isnMonth[today.getMonth()]+today.getDate()+"日 "+isnDay[today.getDay()]);
document.write("/font");}
//--
/script
/body
/html
晕,我可不是看分的面上来的
只是觉得这段代码很简洁,想介绍给楼主而已
js显示当前时间
你的代码有些小问题,至于什么问题,对照着我的看看吧!
html
head
meta http-equiv="Content-Type" content="text/html; charset=utf-8"/ /head
body
script language="javascript"
var cur = new Date();
var y = cur.getFullYear();
var m = cur.getMonth()+1;
var d = cur.getDate();
document.write("当前时间显示:"+y+" 年"+m+"月"+d+"日");
/script
/body
/html
效果就是这样了!很简单的!
希望能帮助到你,望采纳!
js时间代码
!DOCTYPE html
html lang="en"
head
meta charset="UTF-8"
titledateutil-js时间举例/title
!-- script src=""/script--
script src=""/script
/head
body
script type="text/javascript"
console.log(getdate_WMdy_En());//Thurs.Sept.2, 2020
console.log(getdate_yMdhms_T());//2020-9-2 21:41:7
console.log(getdate_WyMdhms_C());//星期四 2020年9月2日 21时38分33秒
/script
/body
/html