Format Date as "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" Format Date as "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" javascript javascript

Format Date as "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"


Call the toISOString() method:

var dt = new Date("30 July 2010 15:05 UTC");document.write(dt.toISOString());// Output://  2010-07-30T15:05:00.000Z


toISOString() will return current UTC time only not the current local time. If you want to get the current local time in yyyy-MM-ddTHH:mm:ss.SSSZ format then you should get the current time using following two methods

Method 1:

console.log(new Date(new Date().toString().split('GMT')[0]+' UTC').toISOString());