DEV Community

Girish Kattel
Girish Kattel

Posted on

What Is a Unix Timestamp? How to Convert Epoch Time to Date (Python, JavaScript, Java, Node.js)

If you’ve seen numbers like 1746959680 in your code or logs and wondered what on earth is this? — welcome to the world of Unix timestamps.

In this quick guide, you’ll learn:

  • ✅ What a Unix timestamp is
  • 📅 How to convert it to a human-readable format
  • 💻 Code examples in Python, JavaScript, Java & Node.js
  • ⚡ A free tool for instant conversion → Unix Timestamp Converter

🤔 What is a Unix Timestamp?

A Unix timestamp (or Epoch time) is the number of seconds that have passed since:

📍 January 1st, 1970 at 00:00:00 UTC

This moment is known as the Unix Epoch — a standard starting point for time in computing systems.

For example:

1746959680 → May 11, 2025, 10:54:40 AM UTC

Enter fullscreen mode Exit fullscreen mode

Unix time is widely used because it’s:

  • Language-agnostic
  • Compact
  • Efficient for calculations and comparisons

🧑‍💻 Why Developers Use Unix Timestamps

Unix timestamps are everywhere for good reasons:

🔁 Easy comparisons — Just subtract two timestamps to get time differences

💽 Lightweight storage — Numbers instead of long date strings

🌐 Universal format — Used in APIs, databases, logs, and analytics


🔁 How to Convert a Unix Timestamp

✅ Use a Free Online Converter

Don’t want to write code? No problem. Paste your timestamp into a tool like:

👉 Unix Timestamp Converter)

Features:

  • Convert timestamps to UTC/local time
  • Convert both seconds and milliseconds
  • Convert from date to timestamp, and vice versa

🐍 Convert in Python

Here’s how to convert a Unix timestamp in Python:

import datetime

timestamp = 1746959680
dt = datetime.datetime.utcfromtimestamp(timestamp)
print(dt.strftime('%Y-%m-%d %H:%M:%S'))
# Output: 2025-05-11 10:54:40
Enter fullscreen mode Exit fullscreen mode

🔄 Want to skip the code? Convert it instantly with this tool


🌐 Convert in Node.js

Node.js uses the same Date object as browser JavaScript, so it’s just as simple:

const timestamp = 1746959680;
const date = new Date(timestamp * 1000);

console.log(date.toISOString());
// Output: 2025-05-11T10:54:40.000Z
Enter fullscreen mode Exit fullscreen mode

If you want local time instead:

console.log(date.toLocaleString());
// Output depends on your system’s locale and timezone
Enter fullscreen mode Exit fullscreen mode

🧠 Pro Tip: Use libraries like dayjs, luxon, or moment for more robust time formatting in Node.js apps.

🔄 Want to skip the code? Convert it instantly with this tool


🌐 Convert in JavaScript

JavaScript works with milliseconds, so multiply by 1000:

const timestamp = 1746959680;
const date = new Date(timestamp * 1000);
console.log(date.toISOString());
// Output: 2025-05-11T10:54:40.000Z
Enter fullscreen mode Exit fullscreen mode

🧠 Note: Always remember JS uses milliseconds, not seconds.

🔄 Want to skip the code? Convert it instantly with this tool


Convert in Java

In Java, use the Instant and ZonedDateTime classes from the java.time package (Java 8+):

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class UnixTimestampConverter {
    public static void main(String[] args) {
        long timestamp = 1746959680L;
        Instant instant = Instant.ofEpochSecond(timestamp);
        ZonedDateTime dateTime = instant.atZone(ZoneId.of("UTC"));

        String formatted = dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        System.out.println(formatted);
        // Output: 2025-05-11 10:54:40
    }
}
Enter fullscreen mode Exit fullscreen mode

This prints the UTC time from the Unix timestamp. You can also adjust the ZoneId for local time.

🔄 Want to skip the code? Convert it instantly with this tool


📈 Bonus: Real-World Uses

You’ll find Unix timestamps in:

🧪 Google Analytics events
🗂️ Backend logs and crash reports
🛢️ Databases like PostgreSQL and MongoDB


📎 Bookmark or Share

If this helped you understand Unix timestamps better:

⭐ Bookmark this page for later
📤 Share it with your dev team
🧭 Explore more tools at unixtimestamp-converter.com

Happy coding! 🚀

Top comments (0)