One data grid for JavaScript, React, Vue & Angular. Sorting, filtering, virtualization, pinning, and CSV export included. Early access $199 $349 → [Get it now]

How to get current timestamp in JavaScript

Getting the current timestamp is essential for logging, performance measurement, and unique ID generation in JavaScript applications. As the creator of CoreUI, I’ve used timestamps extensively in production systems for tracking user interactions and measuring component performance. The most efficient and widely supported method is using the Date.now() static method. This approach provides milliseconds since Unix epoch with minimal overhead and maximum browser compatibility.

Use Date.now() to get the current timestamp as milliseconds since Unix epoch.

const timestamp = Date.now()

The Date.now() method returns the current timestamp as a number representing milliseconds elapsed since January 1, 1970 UTC. This static method doesn’t create a Date object, making it the fastest way to get the current time. The returned value can be used for calculations, logging, or converted back to a Date object when needed.

Best Practice Note:

This is the same approach we use in CoreUI components for performance monitoring and cache invalidation. Avoid new Date().getTime() when you only need the timestamp, as Date.now() is significantly faster and doesn’t create unnecessary objects.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
JavaScript printf equivalent
JavaScript printf equivalent

How to Open All Links in New Tab Using JavaScript
How to Open All Links in New Tab Using JavaScript

How to Remove Underline from Link in CSS
How to Remove Underline from Link in CSS

Understanding and Resolving the “React Must Be in Scope When Using JSX
Understanding and Resolving the “React Must Be in Scope When Using JSX