Javascript Date timeNow()
Date.prototype.timeNow = function(){ return ((this.getHours() < 10)?"0":"") + this.getHours() +":"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes() +":"+ ((this.getSeconds() < 10)?"0":"") + this.getSeconds(); };
Date.prototype.timeNow = function () { return (this.getHours() +":"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes()); } var newDate = new Date(); console.log(newDate.timeNow());/*from w w w .j a va 2 s . c om*/
Date.prototype.timeNow = function() { let retStr = ""; retStr += ((this.getHours() < 10)?"0":"") + this.getHours(); retStr += ":" + ((this.getMinutes() < 10)?"0":"") + this.getMinutes(); return retStr;// www . j av a 2 s . c o m }
// GLOBALS//from w w w . j a va 2 s .c om //Format time as 03:14:15 Date.prototype.timeNow = function () { return ((this.getHours() < 10)?"0":"") + ((this.getHours()>12)?(this.getHours()-12):this.getHours()) + ":" + ((this.getMinutes() < 10)?"0":"") + this.getMinutes() + ":" + ((this.getSeconds() < 10)?"0":"") + this.getSeconds() + ((this.getHours()>12)?(' PM'):' AM'); };
Date.prototype.timeNow = function () { return (this.getHours() < 10 ? '0' : '') + this.getHours() + ':' + (this.getMinutes() < 10 ? '0' : '') + this.getMinutes() + ':' + (this.getSeconds() < 10 ? '0' : '') + this.getSeconds() }