E 'quasi come toISOString
function formatDateTime(date) {
const year = date.getUTCFullYear();
const month = pad(date.getUTCMonth() + 1);
const day = pad(date.getUTCDate());
const hour = pad(date.getUTCHours());
const minute = pad(date.getUTCMinutes());
const second = pad(date.getUTCSeconds());
return `${year}${month}${day}T${hour}${minute}${second}Z`;
}
function pad(i) {
return i < 10 ? `0${i}` : `${i}`;
}
// Example:
const date = new Date('2017-05-31T11:46:54.216Z');
date.toISOString() // '2017-05-31T11:46:54.216Z'
date.toJSON() // '2017-05-31T11:46:54.216Z'
formatDateTime(date) // '20170531T114654Z'
fonte
2017-05-31 11:50:24