node.js – Date.now().toISOString() throwing error not a function

node.js – 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()

node.js – Date.now().toISOString() throwing error not a function

Leave a Reply

Your email address will not be published. Required fields are marked *