Javascript Date toISO8601()

Description

Javascript Date toISO8601()


Date.prototype.toISO8601 = function() {
  function pad(n) {
    return n < 10 ? '0' + n : n;
  }//from w  ww.  j a  va  2  s .  c  o m
  return this.getUTCFullYear() + '-' + pad(this.getUTCMonth() + 1) + '-' + pad(this.getUTCDate()) + 'T' + pad(this.getUTCHours())
   + ':' + pad(this.getUTCMinutes()) + ':' + pad(this.getUTCSeconds()) + 'Z';
};



PreviousNext

Related