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