您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關(guān)如何在html中使用JavaScript獲取系統(tǒng)當(dāng)前時(shí)間,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
具體內(nèi)容如下
<html> <head> <STYLE> TD { FONT-SIZE: 12px; COLOR: #ffffff; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif } </STYLE> <SCRIPT language=JavaScript> function tick() { var years,months,days,hours, minutes, seconds; var intYears,intMonths,intDays,intHours, intMinutes, intSeconds; var today; today = new Date(); //系統(tǒng)當(dāng)前時(shí)間 intYears = today.getFullYear(); //得到年份,getFullYear()比getYear()更普適 intMonths = today.getMonth() + 1; //得到月份,要加1 intDays = today.getDate(); //得到日期 intHours = today.getHours(); //得到小時(shí) intMinutes = today.getMinutes(); //得到分鐘 intSeconds = today.getSeconds(); //得到秒鐘 years = intYears + "-"; if(intMonths < 10 ){ months = "0" + intMonths +"-"; } else { months = intMonths +"-"; } if(intDays < 10 ){ days = "0" + intDays +" "; } else { days = intDays + " "; } if (intHours == 0) { hours = "00:"; } else if (intHours < 10) { hours = "0" + intHours+":"; } else { hours = intHours + ":"; } if (intMinutes < 10) { minutes = "0"+intMinutes+":"; } else { minutes = intMinutes+":"; } if (intSeconds < 10) { seconds = "0"+intSeconds+" "; } else { seconds = intSeconds+" "; } timeString = years+months+days+hours+minutes+seconds; Clock.innerHTML = timeString; window.setTimeout("tick();", 1000); } window.onload = tick; </SCRIPT> </head> <BODY leftMargin=0 topMargin=0 marginwidth="0" marginheight="0"> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TR bgColor=#73a3d4 height=40> <TD noWrap align=right width=209 ><SPAN id="Clock"></SPAN></TD> </TR> </TABLE> </BODY> </HTML>
以上就是如何在html中使用JavaScript獲取系統(tǒng)當(dāng)前時(shí)間,小編相信有部分知識點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見到或用到的。希望你能通過這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。