Javascript Date format()
Date.prototype.format = function( ) { var yyyy = this.getFullYear().toString(); var mm = (this.getMonth()+1).toString(); var dd = this.getDate().toString(); return yyyy + (mm[1] ? mm : '0'+mm[0]) + (dd[1] ? dd : '0' +dd[0]) }
Date.prototype.format = function () { 'use strict';/* w w w . j a v a 2 s.com*/ var d = this.getDate() , m = this.getMonth() + 1 , y = this.getFullYear(); return '' + y + '-' + (m<=9 ? '0' + m : m) + '-' + (d <= 9 ? '0' + d : d); };
function ISODateString(aDate) { function pad(aNumber) { return aNumber < 10 ? '0' + aNumber : aNumber; }//from w ww . j a va2 s . c o m return aDate.getUTCFullYear() + '-' + pad(aDate.getUTCMonth() + 1) + '-' + pad(aDate.getUTCDate()); } // For convenience... Date.prototype.format = function () { return ISODateString(this); };
Date.prototype.format = function () { var dt = this; return dt.getFullYear().pad(4) + '-' + (dt.getMonth() + 1).pad(2) + '-' + dt.getDay().pad(2) + ' ' + dt.getHours().pad(2) + ':' + dt.getMinutes().pad(2); }
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ function ISODateString(aDate) { function pad(aNumber) { return aNumber < 10 ? '0' + aNumber : aNumber; }/* ww w . ja va2 s.com*/ return aDate.getUTCFullYear() + '-' + pad(aDate.getUTCMonth() + 1) + '-' + pad(aDate.getUTCDate()); } // For convenience... Date.prototype.format = function () { return ISODateString(this); };