title | category | date | topics |
---|---|---|---|
Get the current timestamp |
Tip |
2021-02-27 16:43:00 +7 |
JavaScript |
There are a few ways to get the current timestamp. All method return the number of milliseconds:
new Date().getTime();
Date.now();
// These method are the same
// The unary operator (`+`) calls the `valueOf` method automatically
+new Date();
new Date().valueOf();
Take a look at this snippet if you want to get the current time in seconds