How do you get a timestamp in JavaScript? 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. Answer: Short & Snazzy: + new Date() A unary operator like plus triggers the valueOf method in the Date object and it returns the time-stamp (without any alteration). Details: On almost all current browsers you can use Date.now() to get the UTC timestamp in milliseconds; a notable exception to this is IE8