What is Unix Epoch Time?
Unix Epoch Time is the number of seconds or milliseconds passed since January 1, 1970 (UTC).

This starting point is called the Epoch (0 time).
Why JavaScript uses 1970?
- It comes from the Unix operating system
- It gives a standard way to calculate time
- Easy for computers to:
- Compare dates
- Store time efficiently
- Perform calculations
How JavaScript Handles Time
JavaScript uses the Date object to work with time. Internally, it stores time as milliseconds since the epoch. Functions like Date.now() return the current timestamp, which is useful for tracking events or measuring time differences.
Key Points:
- Date.now() → current time in milliseconds
- new Date() → readable date format
- Time stored as a number (ms)
- Easy to compare two times
Converting Epoch Time
Epoch time can be converted into a human-readable date using the Date object. Similarly, you can convert milliseconds into seconds by dividing by 1000. This flexibility allows developers to use time in different formats based on requirements.
Key Points:
- new Date(milliseconds) → readable date
- Divide by 1000 → get seconds
- Used for formatting date & time
- Supports time calculations
How Unix Epoch Time is Used in JavaScript
Working with Timers





Top comments (0)