bessarabov bessarabov - 1 year ago 97
Javascript Question

How to output date in javascript in ISO 8601 without milliseconds and with Z

Here is a standart 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

Answer Source

Simple way:

console.log( now.toISOString().split('.')[0]+"Z" );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download