var time = { timeFormat: config.time.timeFormat || 24, dateLocation: '.date', timeLocation: '.time', updateInterval: 1000, intervalId: null }; time.updateTime = function () { var _now = moment(), _date = _now.format('dddd, LL'); $(this.dateLocation).html(_date); $(this.timeLocation).html(_now.format(this._timeFormat+':mm[]ss[]')); } time.init = function () { if (parseInt(time.timeFormat) === 12) { time._timeFormat = 'hh' } else { time._timeFormat = 'HH'; } this.intervalId = setInterval(function () { this.updateTime(); }.bind(this), 1000); }