CoreUI ONE — 250+ PRO components and 25+ admin templates for React, Angular, Vue, Bootstrap and Next.js, plus Data Grid, Scheduler, 4,300+ PRO icons and the Next.js boilerplate. One license. → See what you get

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.
How to validate an email address in JavaScript
How to validate an email address in JavaScript

What is the difference between typeof and instanceof in JavaScript
What is the difference between typeof and instanceof in JavaScript

How to conditionally add attributes to React components
How to conditionally add attributes to React components

How to force a React component to re-render
How to force a React component to re-render