JS中使用定时动态获取系统当前时间
生活随笔
收集整理的這篇文章主要介紹了
JS中使用定时动态获取系统当前时间
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
場(chǎng)景
實(shí)現(xiàn)
html代碼:
<div class="form-group col-md-4"><label>調(diào)整時(shí)間:</label><input type="text" readonly="readonly" id="finishTime" class="form-control" /> </div>js代碼:
?setInterval(today, 1000);today函數(shù):
function today(){//構(gòu)建方法var today=new Date();//new 出當(dāng)前時(shí)間var h=today.getFullYear();//獲取年var m=today.getMonth()+1;//獲取月var d=today.getDate();//獲取日var H = today.getHours();//獲取時(shí)var M = today.getMinutes();//獲取分var S = today.getSeconds();//獲取秒document.getElementById('finishTime').value= h+"-"+m+"-"+d+" "+H+":"+M+":"+S; //返回 年-月-日 時(shí):分:秒}?
總結(jié)
以上是生活随笔為你收集整理的JS中使用定时动态获取系统当前时间的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SpringBoot中使用thymele
- 下一篇: SpringBoot+Thymeleaf