怎么理解推遲2小時(shí)啊
<!DOCTYPE?html> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> <title>日期對(duì)象?</title> <script?type="text/javascript"> ?var?mydate=new?Date(); ??document.write("當(dāng)前時(shí)間:"+mydate+"<br>"); ??mydate.setTime(mydate.getTime()?+?2*?60?*?60?*?1000); ??document.write("推遲二小時(shí)時(shí)間:"?+?mydate); </script> </head> <body> </body> </html>
輸出結(jié)果
當(dāng)前時(shí)間:Thu Oct 20 2016 15:16:27 GMT+0800
推遲二小時(shí)時(shí)間:Thu Oct 20 2016 17:16:27 GMT+0800
2016-10-20
1秒是1000毫秒,一分鐘是60秒,一小時(shí)是60分鐘。一個(gè)小時(shí)就是60?*?60?*?1000毫秒,兩個(gè)小時(shí)就是60?*?60?*?1000*2毫秒,js中的時(shí)間是以毫秒為單位。
2016-10-20
get/setTime() 返回/設(shè)置時(shí)間,單位毫秒數(shù)。