Back
How can I get a timestamp in JavaScript?
Something similar to Unix's timestamp, that is, a single number that represents the current time and date. Either as a number or a string.
For getting a timestamp in JavaScript almost all current browsers you can use Date.now()method and it will return the UTC timestamp in milliseconds.
See the code below:-
if (!Date.now) { Date.now = function() { return new Date().getTime(); } }
if (!Date.now) {
Date.now = function() {
return new Date().getTime();
}
31k questions
32.8k answers
501 comments
693 users