Javascript Date toISO()

Description

Javascript Date toISO()

Date.prototype.toISO = function() {
    var tem, A = this.toUTCArray(), i = 0;
    A[1] += 1;//from   w  w w  . j  a  va 2s  .  c o  m
    while(i++ < 7) {
        tem = A[i];
        if(tem < 10) {
            A[i] = '0' + tem;
        }
    }
    return A.splice(0, 3).join('-') + 'T' + A.join(':') + 'Z';
}



PreviousNext

Related