Sometimes, we want to fix JavaScript getTime() is not a function error.
In this article, we’ll look at how to fix JavaScript getTime() is not a function error.
How to fix JavaScript getTime() is not a function error?
To fix JavaScript getTime() is not a function error, we should make sure we’re calling getTime
on date objects.
For instance, we write
const res = new Date(dat1).getTime() > new Date(dat2).getTime();
so that we’re calling getTime
on 2 date objects to compare their timestamps.
Conclusion
To fix JavaScript getTime() is not a function error, we should make sure we’re calling getTime
on date objects.