I am trying to display the most current date and time that occurs every second but the output is staying the same. I dont want to use jquery because I am learning how to do this with javascript. The display function is being called by the body on onload.
function display()
{
var today = new Date();
var month = today.getMonth();
var day = today.getDay();
var year = today.getFullYear();
var hour = today.getHours() > 12 ? today.getHours() - 12 : today.getHours();
var minute = today.getMinutes();
var seconds = today.getSeconds();
var milliseconds = today.getMilliseconds();
var output = month + '/' + day + '/' + year + ' - ' +
hour + ':' + minute + ':' + seconds + ':' + milliseconds;
setInterval(function() {
document.write(output);
}, 3000);
}