while (endOfMonth == false) { tableRow = document.createElement('tr'); for (i = 0; 1 < 7; i++) { if (currentDay.getTime() == lastDisplay.getTime()) { endOfMonth = true; } alert(currentDay+"\n"+currentDay.getTime()+"\n"+lastDisplay+"\n"+lastDisplay.getTime()+"\n"+endOfMonth); tableCell = document.createElement('td'); tableRow.appendChild(tableCell); currentDay = currentDay.addHours(24); } table.appendChild(tableRow); }