<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>date_function</title> </head> <body> <script> function testDate(){ var date = new Date(); var myDate = new Date("2017/12/25 17:00:00"); console.log(date); // Mon Oct 08 2018 15:53:36 GMT+0800 (中国标准时间) console.log(myDate); // Mon Dec 25 2017 17:00:00 GMT+0800 (中国标准时间) } function testFor(){ var start = new Date(); //查看打印1-10000所有的数字用了多少时间 for(var i=1;i<=10000;i++){ console.log(i); } var end = new Date(); var duration = end.getTime() - start.getTime(); console.log("共花费"+duration+"毫秒"); // 共花费1695毫秒 } </script> <button onclick="testDate()">testDate</button> <button onclick="testFor()">testFor</button> </body> </html>
js date_function.html
猜你喜欢
转载自blog.csdn.net/weixin_42193179/article/details/88988723
今日推荐
周排行