課程
/前端開(kāi)發(fā)
/JavaScript
/JavaScript進(jìn)階篇
我這么寫(xiě)但是屏幕打印出來(lái)的原本的時(shí)間和更改后的時(shí)間相比并沒(méi)有什么變化
2018-11-04
源自:JavaScript進(jìn)階篇 7-5
正在回答
就是設(shè)置原本的時(shí)間往后推遲兩小時(shí)。代碼沒(méi)問(wèn)題
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
var date = new Date();
document.write("當(dāng)前時(shí)間:" + date +"<br\>");
date.setTime( date.getTime() + 2*60*60*1000 );
document.write(" 修改后的時(shí)間: "+ date );
</script>
</head>
<body></body>
</html>
沒(méi)看出來(lái)錯(cuò)哪了,總共沒(méi)幾行,復(fù)制別人成功的代碼 ,用一半一半的排除法試下吧。
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>日期對(duì)象 </title>
?var mydate=new Date();
? document.write("當(dāng)前時(shí)間:"+mydate+"<br>");
? mydate.setTime(mydate.getTime()+ 2* 60 * 60 * 1000);
? document.write("推遲二小時(shí)時(shí)間:" + mydate);
<body>
</body>
我這樣都可以也,邏輯沒(méi)有問(wèn)題,注意檢查一下符號(hào)問(wèn)題,如括號(hào),引號(hào)等這些細(xì)節(jié)問(wèn)題,確保是在英文狀態(tài)下輸入的符號(hào)
var newtime =?新時(shí)間;
document.write('推遲二小時(shí)的時(shí)間:'+ newtime);
qq_慕桂英8249707 提問(wèn)者
Lightonthekey 回復(fù) qq_慕桂英8249707 提問(wèn)者
舉報(bào)
本課程從如何插入JS代碼開(kāi)始,帶您進(jìn)入網(wǎng)頁(yè)動(dòng)態(tài)交互世界
1 回答推遲一小時(shí)的表達(dá)式是什么意思為什么是乘號(hào)
2 回答關(guān)于推遲時(shí)間問(wèn)題
1 回答num++到底是什么意思?
2 回答交互時(shí)間是什么意思
4 回答返回值到底是個(gè)什么意思?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-12-06
就是設(shè)置原本的時(shí)間往后推遲兩小時(shí)。代碼沒(méi)問(wèn)題
2018-11-22
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
var date = new Date();
document.write("當(dāng)前時(shí)間:" + date +"<br\>");
date.setTime( date.getTime() + 2*60*60*1000 );
document.write(" 修改后的時(shí)間: "+ date );
</script>
</head>
<body></body>
</html>
沒(méi)看出來(lái)錯(cuò)哪了,總共沒(méi)幾行,復(fù)制別人成功的代碼 ,用一半一半的排除法試下吧。
2018-11-06
<!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>
我這樣都可以也,邏輯沒(méi)有問(wèn)題,注意檢查一下符號(hào)問(wèn)題,如括號(hào),引號(hào)等這些細(xì)節(jié)問(wèn)題,確保是在英文狀態(tài)下輸入的符號(hào)
2018-11-05
var newtime =?新時(shí)間;
document.write('推遲二小時(shí)的時(shí)間:'+ newtime);