小提琴:https://jsfiddle.net/kxqndpk1/2/加入今天和明天的日期盈我的日期
var months = ['January','February','March','April','May','June','July',
'August','September','October','November','December'];
var today = new Date();
today.setTime(today.getTime());
document.getElementById("spanToday").innerHTML = months[today.getMonth()] + " " + today.getDate()+ ", " + today.getFullYear();
var months = ['January','February','March','April','May','June','July',
'August','September','October','November','December'];
var tomorrow = new Date();
tomorrow.setTime(tomorrow.getTime() + (1000*3600*24));
document.getElementById("spanTomorrow").innerHTML = months[tomorrow.getMonth()] + " " + tomorrow.getDate()+ ", " + tomorrow.getFullYear();
<span id="spanToday"></span>, at 10:00 AM
<br>
<span id="spanTomorrow"></span>, at 10:00 AM
<br><br>
Eastern Time (EST)
的目標是添加適當的一天,在2日的前面。
你要添加什麼日子?當天? –
**適當的日期是什麼意思**星期一,星期二等**或** 1,2 ..,30 **? – SwapNeil
另外爲什麼你創建兩個相同的變量.. ?? 'var months = ['January','February',..' – SwapNeil