How I would go about displaying the time in a certain format (h:mm:ss a)? I can find examples for (hh:mm:ss a).
E.g of (h:mm:ss a) 9:10:23 PM
E.g of (hh:mm:ss a) 09:10:23 PM
EDIT: I achieved this my question with the following:
<i>var formatTime = (function () {
return function (dt) {
var formatted = '';
if (dt) {
var hours24 = dt.getHours();
var hours = ((hours24 + 11) % 12) + 1;
formatted = [formatted, [hours, addZero(dt.getMinutes())].join(":"), hours24 > 11 ? "PM" : "AM"].join(" ");
}
return formatted;
}
})();
alert(formatTime(new Date())); </i>