這裏是我的程序:添加逗號到JavaScript計數進位定時器
<script>
var montharray = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
function countup(yr, m, d) {
var today = new Date()
var todayy = today.getYear()
if (todayy < 1000) todayy += 1900
var todaym = today.getMonth()
var todayd = today.getDate()
var todaystring = montharray[todaym] + " " + todayd + ", " + todayy
var paststring = montharray[m - 1] + " " + d + ", " + yr
var difference = (Math.round((Date.parse(todaystring) - Date.parse(paststring))/(24 * 60 * 60 * 1000)) * 1)
difference += ""
document.write("" + difference + "")
}
//enter the count up date using the format year/month/day
countup(2007, 01, 24)
</script>
我試圖讓在千位(例如的1,234代替1234)輸出插入逗號。我怎樣才能做到這一點?
這裏沒有真正的問題。投票結束。 –
@Delan,我認爲這個問題是真實的,它只是需要一些清理工作。 –
@Eric爲什麼你需要將空字符串('「」')添加到'差異'? –