Moment Live Timestamp
Live timestamp using moment.js.
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.1/moment.min.js"></script>
<h1>UTC Timestamps</h1>
<h2 class="livestamp"></h2>
<h4 class="livestamp" data-format="MMMM Do YYYY, h:mm:ss a"></h4>
<p class="livestamp"></p>
JavaScript
var activateTimestamps = function() {
var updateLiveTimestamp = function($timestamp, format) {
var timestamp = moment().utc().format(format);
$timestamp.html(timestamp);
};
$('.livestamp').each(function(index, element) {
var $element = $(element);
var timestampFormat = $element.data('format') || defaultFormat;
var callback = function() {
updateLiveTimestamp($element, timestampFormat);
};
setInterval(callback, 1000);
});
};
activateTimestamps();