How to obtain the Timestamp in Javascript

In order to retrieve the timestamp in Javascript in Milliseconds, follow the simple methods below.

1 – Using : + new Date()

You might think the syntax is wrong ! As you can see in the snapshot above however, the syntax is rather correct since the Plus sign invokes the valueOf() of the Date object.

Read: Should You Learn JavaScript, Advice for Newbie Web Developers

2 – Using :

This works with most browsers except IE8 and earlier versions.In this case, you might want to use the following workaround:

if (! { = function() { return new Date().getTime(); } } // javascript

Read: How to remove a property from a Javascript Object

3 Using : new Date().getTime();

If you do not like the output format, you could try out the following command:

new Date().toISOString() // new Date in javascript – timestamp to date in javascript

Answer due to Daithi.


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.


Nikolaus Oosterhof

Nikolaus has a degree in software development. He is passionate about gadgets with a screen, nostalgic for phones, a retired gamer and open source programmer. He likes also to write about macOS and Windows. design web pages and debug long programs!

Leave a Reply