Here is a standard way to serialise date as ISO 8601 string in JavaScript:
var now = new Date();
console.log( now.toISOString() );
// outputs '2015-12-02T21:45:22.279Z'
I need just the same output, but without milliseconds. How can I output 2015-12-02T21:45:22Z
?