在html页面怎么显示系统时间

在html页面怎么显示系统时间,第1张

需要准备的材料分别有:电脑、浏览器、html编辑器

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<script>标签中,输入js代码:$('body').append(new Date())。

3、浏览器运行index.html页面,此时页面显示出了系统时间

<script language="javascript" type="text/javascript">

function getFullStringTime(){

var currentDate = new Date()

var strMinute = currentDate.getMinutes()<10?("0"+currentDate.getMinutes()):currentDate.getMinutes()

var strSecond = currentDate.getSeconds()<10?("0"+currentDate.getSeconds()):currentDate.getSeconds()

with(document){

write("现在时间是:","<br>")

if(currentDate.getDay()==0){

write(currentDate.getYear()+1900,"年",currentDate.getMonth()+1,"月",currentDate.getDate(),"日"," ","星期日"," ",currentDate.getHours(),":",strMinute,":",strSecond)

}else{

write(currentDate.getYear()+1900,"年",currentDate.getMonth()+1,"月",currentDate.getDate(),"日"," ","星期日"," ",currentDate.getHours(),":",strMinute,":",strSecond)

}

}

}

getFullStringTime()

</script>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6124348.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存