When computers need to store or compare times, working with strings like "May 5, 2026 at 11:39 PM" gets complicated fast. That's where Unix timestamps come in — they represent a moment in time as a single integer: the number of seconds elapsed since January 1, 1970 at 00:00:00 UTC. Arithmetic and comparisons become trivial with just a number.
Why 1970? It was simply a convenient round date chosen when Unix was being designed. Today, timestamps are 10-digit numbers like 1777991991.
In JavaScript, Date.now() gives you the current time in milliseconds (thousandths of a second). Since Unix timestamps use seconds, we divide by 1000. Going the other direction is just as easy: new Date(ts * 1000) creates a Date object from a timestamp, which can then be formatted with toLocaleString() for a human-readable string or toISOString() for the standard ISO 8601 format.
The live timestamp counter updates every second using setInterval.