Javascript Date niceFormat()

Description

Javascript Date niceFormat()


Date.prototype.niceFormat = function () {
  function pad2(n) {
    return (n < 10 ? '0' : '') + n;
  }/*  w  w  w. j  a  va2 s  . c o  m*/
  return this.getFullYear() + '-' +
    pad2(this.getMonth() + 1) + '-' +
    pad2(this.getDate()) + ' ' +
    pad2(this.getHours()) + ':' +
    pad2(this.getMinutes()) + ':' +
    pad2(this.getSeconds());
};



PreviousNext

Related