This is a good method. I'm a bit weary of creating an array to simply prepend a "0" to the number though. Here's what I have used a bunch:
Matthew
isoDate = function( d ) {
//defaults to new date
d = d || new Date();
function pad( n ) {
return n < 10 ? '0' + n : n;
}
return d.getUTCFullYear() + '-' +
pad( d.getUTCMonth() +1 ) + '-' +
pad( d.getUTCDate() ) + 'T' +
pad( d.getUTCHours() ) + ':' +
pad( d.getUTCMinutes() )+ ':' +
pad( d.getUTCSeconds() )+ 'Z';
},
Cheers,Matthew