Date.now().toISOString() throwing error "not a function"

Date.now() returns a number which represents the number of milliseconds elapsed since the UNIX epoch. The toISOString method cannot be called on a number, but only on a Date object, like this:

var now = new Date();
var isoString = now.toISOString();

Or in one single line:

new Date().toISOString()