Categories
JavaScript Answers

How to fix JavaScript Date().getTime() is not a function?

Spread the love

To fix JavaScript Date().getTime() is not a function, we need the new keyword before Date.

For instance, we write

const now = new Date().getTime();

to create a new date object with new Date().

And then we call getTime to get the current timestamp from the date object.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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