语言吧技术网欢迎您投稿,程序员的世界我懂你!=====>点此登录投搞
当前位置: 首页 >>JAVASCRIPT >>JS实战技巧 >>JS移动DIV >>纯JS实现实时刷新时间显示代码

纯JS实现实时刷新时间显示代码

2019/7/21 9:10:51 0人评论 309次 作者:admin

纯JS实现显示刷新显示…

<script>

var dayarray=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六")

var montharray=new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月")

function getthedate(){

var mydate=new Date()

var year=mydate.getYear()

if (year < 1000)

year+=1900

var day=mydate.getDay()

var month=mydate.getMonth()

var daym=mydate.getDate()

if (daym<10)

daym="0"+daym

var hours=mydate.getHours()

var minutes=mydate.getMinutes()

var seconds=mydate.getSeconds()

var dn="AM"

if (hours>=12)

dn="PM"

if (hours>12){

hours=hours-12

}

if (hours==0)

hours=12

if (minutes<=9)

minutes="0"+minutes

if (seconds<=9)

seconds="0"+seconds

//change font size here

var cdate=""+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn+"";

document.getElementById("hdhcmsclock").innerHTML=cdate;

}

setInterval("getthedate()",1000)

 </script>

<span id="hdhcmsclock" style="width:250px;"></span>


上一篇:没有了

下一篇:没有了

相关文章

CopyRight:2007-2018 语言吧 备案ICP:湘ICP备09009000号-15 http://www.yuyanba.com
欢迎【广东省 广州市】的朋友
内容与素材部分来源于网络,如有侵权请告知删除
分享按钮