本文目錄一覽:
關於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
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/248321.html