需要准备的材料分别有:电脑、浏览器、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>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)