How to output date in javascript in ISO 8601 without milliseconds and with Z
Use slice to remove the undesired part
var now = new Date();
alert( now.toISOString().slice(0,-5)+"Z");
This is the solution:
var now = new Date();
var str = now.toISOString();
var res = str.replace(/\.[0-9]{3}/, '');
alert(res);
Finds the . (dot) and removes 3 characters.
http://jsfiddle.net/boglab/wzudeyxL/7/
Simple way:
console.log( new Date().toISOString().split('.')[0]+"Z" );