100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 渡一教育公开课web前端开发JavaScript精英课学习笔记(十三)Date对象

渡一教育公开课web前端开发JavaScript精英课学习笔记(十三)Date对象

时间:2022-03-02 07:14:25

相关推荐

渡一教育公开课web前端开发JavaScript精英课学习笔记(十三)Date对象

Date

<h1>日期对象</h1><script type = "text/javascript">//日期对象 是系统提供的已封装好对象,操作日期的函数。var date = new Date();console.log(date.getDate());console.log(date.getDay());console.log(date.getMonth());console.log(date.getYear());console.log(date.getFullYear());console.log(date.getHours());console.log(date.getMinutes());console.log(date.getSeconds());console.log(date.getMilliseconds());console.log(date.getTime());//1970年1月1日后的毫秒数,计算机的纪元时间。//时间戳var fristTime = new Date().getTime();for(var i = 0 ;i < 100000000;i++);var lastTime = new Date().getTime();console.log(lastTime - fristTime);//定时循环器 准不准var ftime = new Date().getTime();//setInterval可以传入字符,执行时解释为代码。var timer = setInterval(function(){var ltime = new Date().getTime();console.log(ltime - ftime);ftime = ltime;},1000);function stopTimer(){clearInterval(timer);console.log('Stop Timer');}var timer1 = setTimeout(function(){console.log('setTimeout');stopTimer();},5000);//clearTimeout(timer1);//停止定时执行器</script>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。