Skip to content
🛠️ToolsShed

Unix Timestamp Converter

Convert between Unix timestamps and human-readable dates.

Current Unix timestamp
Seconds since Jan 1, 1970 (UTC)

Timestamp → Date

Date → Timestamp

About this tool

A Unix timestamp is a simple yet powerful way to represent any moment in time using a single number. Instead of worrying about time zones, date formats, or calendar systems, developers, engineers, and data analysts worldwide rely on timestamps to synchronize systems, store historical data, and communicate precise points in time. Whether you're working with logs from a web server, scheduling automated tasks, or analyzing events across time, Unix timestamps provide a universal language that doesn't change regardless of location or local settings.

This tool converts between Unix timestamps (in seconds or milliseconds) and human-readable dates. Simply enter a timestamp to see the corresponding date and time in your local timezone, or input any date to generate its Unix timestamp. The converter automatically detects whether you've entered seconds or milliseconds, making it seamless to work with APIs, databases, and programming languages that may use different timestamp units. It also shows UTC time for reference, helping you understand both the absolute moment in time and how it translates to your location.

Programmers use this tool when debugging logs, setting up scheduled jobs, working with APIs, or integrating systems that communicate timestamps across different platforms. It's equally useful for understanding when events actually happened in archived data, converting between timestamp formats used by different software, or simply learning about how computers track time. No account needed—just open and convert instantly in your browser.

Frequently Asked Questions

Code Implementation

from datetime import datetime, timezone

# Current Unix timestamp
now_ts = int(datetime.now(timezone.utc).timestamp())
print(f"Current Unix timestamp (s):  {now_ts}")
print(f"Current Unix timestamp (ms): {now_ts * 1000}")

# Timestamp to datetime
def ts_to_datetime(ts: int | float, unit: str = "s") -> datetime:
    """Convert Unix timestamp to UTC datetime."""
    if unit == "ms":
        ts = ts / 1000
    return datetime.fromtimestamp(ts, tz=timezone.utc)

# Datetime to timestamp
def datetime_to_ts(dt: datetime, unit: str = "s") -> int:
    """Convert datetime to Unix timestamp."""
    ts = dt.timestamp()
    return int(ts * 1000) if unit == "ms" else int(ts)

# Examples
ts = 1700000000
dt = ts_to_datetime(ts)
print(f"1700000000 -> {dt.isoformat()}")  # 2023-11-14T22:13:20+00:00

dt2 = datetime(2024, 1, 1, tzinfo=timezone.utc)
print(f"2024-01-01 UTC -> {datetime_to_ts(dt2)}")  # 1704067200

# Parse any date string to timestamp
from datetime import datetime
dt3 = datetime.fromisoformat("2024-06-15T12:00:00+09:00")
print(f"2024-06-15T12:00:00+09:00 -> {datetime_to_ts(dt3)}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.