日期和时间案例

原创 2019-01-07 21:30:07 198
摘要:<!DOCTYPE html><html><head> <title>事件</title> <div style="width: 140px;height: 50px;bottom: 5px;background: #ccc;"><h1>北京时间<h1></div><

<!DOCTYPE html>

<html>

<head>

<title>事件</title>

<div style="width: 140px;height: 50px;bottom: 5px;background: #ccc;"><h1>北京时间<h1></div>

</head>

<body>

<script type="text/javascript">

var myday=new Date()

document.write(myday+"<br>")

document.write(myday.getFullYear()+"年")

var month=new Array(12)

    month[0]="1月"

    month[1]="二月"

    month[2]="三月"

    month[3]="四月"

    month[4]="五月"

    month[5]="六月"

    month[6]="七月"

    month[7]="八月"

    month[8]="九月"

    month[9]="十月"

    month[10]="十一月"

    month[11]="十二月"

   document.write(""+month[myday.getMonth()])

document.write(""+myday.getDate()+"日")

document.write(""+myday.getHours()+"时")

document.write(myday.getMinutes()+"分")

document.write("星期"+myday.getDay())

</script>

</body>

</html>


批改老师:天蓬老师批改时间:2019-01-08 09:26:26
老师总结:document.write(""+myday.getDate()+"日"), 以后用console.log(),发到控制台显示

发布手记

热门词条