Displaying current date and time using JavaScript and HTML time tag
Semantic markup is less important for dynamically generated HTML than it is for server-generated HTML, but it is a laudable goal nonetheless.  If you're going to produce a datetime attribute for machine consumption, then I suggest using T as the delimiter between the date and time, as recommended by ISO 8601.

Since you frequently need to zero-pad a number, you should define a function for it.

For clarity, you should avoid excessively long lines of code.  In addition, I think it would be a good idea to define separate functions for each of the datetime formats.

I would eliminate the hourap array, since it's not that difficult to achieve the same effect programmatically.

The timeDiv variable refers to a &lt;time&gt; element, not a &lt;div&gt;, and should therefore be renamed.

The semicolon after the final if block is unusual.



var MONTH_NAME = ['January', 'Febuary', 'March', 'April', 'May', 'June',
                  'July', 'August', 'September', 'October', 'November', 'December'];
function showTime() {
    function twoDigit(n) {
        return ('0' + n).slice(-2);
    }
    function iso8601(date) {
        return date.getFullYear() +
               '-' + twoDigit(1 + date.getMonth()) +
               '-' + twoDigit(date.getDate()) +
               'T' + twoDigit(date.getHours()) +
               ':' + twoDigit(date.getMinutes());
    }
    function en_US(date) {
        var h = date.getHours() % 12;
        return MONTH_NAME[date.getMonth()] +
               ' '  + date.getDate() +
               ', ' + date.getFullYear() +
               '&lt;br /&gt;' + (h == 0 ? 12 : h) +
               ':'  + twoDigit(date.getMinutes()) +
               ' ' + (date.getHours() &lt; 12 ? 'am' : 'pm');
    }
    
    var timeEl = document.getElementById('time');
    if (timeEl !== null) {
        var now = new Date();
        timeEl.innerHTML = en_US(now);
        timeDiv.setAttribute('datetime', iso8601(now));
    }
};
setInterval(showTime, 1000);
&lt;time id="time"&gt;&lt;/time&gt;