当前时间获取

原创 2018-11-12 12:15:12 243
摘要:获取其他时间元素之前需要先获取当前时间var time=new Date( );document.write(time);获取年份document.write(time.getFullYear( ));获取月份document.write(time.getMonth( ));获取日期document.write(time.getDate( ));获取星期document.write(time.ge

获取其他时间元素之前需要先获取当前时间

var time=new Date( );

document.write(time);

获取年份document.write(time.getFullYear( ));

获取月份document.write(time.getMonth( ));

获取日期document.write(time.getDate( ));

获取星期document.write(time.getDay( ));

获取小时document.write(time.getHours( ));

获取分钟document.write(time.getMinutes( ));

获取秒钟document.write(time.getSwconds( ));

改变月份输出显示文本

var monte=new Array(12)

month[0]="1月”

month[1]="2月”

month[2]="3月”

month[3]="4月”

。。。

month[11]="12月”

document.write(month[time.getMonth( )])

其他同理

1.png

2.png

批改老师:灭绝师太批改时间:2018-11-12 12:48:10
老师总结:非常ok! 代码习惯也比较清晰!继续保持啊!加油!

发布手记

热门词条