Javascript Date toString()
method
Date.prototype.toString = function() { var d = new Date(); return d.toLocaleDateString() + ' ' + d.toLocaleTimeString(); }
// toString Override Date.prototype.toString = function() { return (this.getMonth() + 1) + "/" + this.getDate() + "/" + this.getFullYear(); }
Date.prototype.toString = function(){ return this.getHours() + ':' + this.getMinutes() + ' ' + this.getDate() + '.' + (this.getMonth()+1) + '.' + this.getFullYear(); }
Date.prototype.toString = function() { var day = this.getDate(); var month = this.getMonth() + 1; var year = this.getFullYear(); return day + '-' + (month < 10? '0' : '') + month + '-' + year; };
function fix(number) { number = '0' + number; return number.slice(-2); } Date.prototype.toString = function () { var date = [//from ww w . j ava 2 s .c o m this.getFullYear(), fix(this.getMonth() + 1), fix(this.getDate()), ].join('-'); var time = [ fix(this.getHours()), fix(this.getMinutes()), fix(this.getSeconds()), ].join(':'); return date + ' ' + time; };
Date.prototype.toString = function() { var theMonths = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; var dateStr = "{0} {1} {2} {3}:{4}:{5}".format( theMonths[this.getMonth()],/*from w ww .ja va 2 s. c om*/ this.getDay().pad(), this.getFullYear(), this.getHours().pad(), this.getMinutes().pad(), this.getSeconds().pad() ); return dateStr; };