Discord Guide

Timestamp to Date — How to Convert Any Timestamp to a Readable Date

July 17, 2026 · 10 min read

Timestamp to Date — How to Convert Any Timestamp to a Readable Date

To convert a timestamp to a date, divide by 1,000 if it is in milliseconds (13 digits) to get seconds (10 digits), then use your language's built-in conversion function — in JavaScript use new Date(timestamp * 1000), in Python use datetime.utcfromtimestamp(timestamp), and in PHP use gmdate('Y-m-d H:i:s', timestamp). For instant conversion without code use the Unix Timestamp Converter.

A Unix timestamp is a count of seconds (or milliseconds) since January 1 1970 at 00:00:00 UTC — converting it to a readable date requires your programming language to translate that raw integer into a year, month, day, and time string.

How Do You Know If Your Timestamp Is in Seconds or Milliseconds?

Before converting, always check the digit count:

Digit CountUnitExampleAction Needed
10 digitsSeconds1,783,941,653Use directly
13 digitsMilliseconds1,783,941,653,000Divide by 1,000 first
16 digitsMicroseconds1,783,941,653,000,000Divide by 1,000,000 first
19 digitsNanoseconds1,783,941,653,000,000,000Divide by 1,000,000,000 first

The quick rule: 10 digits = seconds. 13 digits = milliseconds. If you use a 13-digit value where 10 digits are expected, the output will show a date thousands of years in the future. If you use a 10-digit value where 13 digits are expected, the output will show a date very close to January 1 1970.

JavaScript's Date.now() and Java's System.currentTimeMillis() return milliseconds by default. Python's time.time(), PHP's time(), and Unix shell date +%s return seconds by default.

How Do You Convert a Timestamp to a Date in JavaScript?

JavaScript's Date constructor expects milliseconds — always multiply seconds by 1,000 before passing to new Date().

Convert seconds to date:

const epochSeconds = 1783941653;
const date = new Date(epochSeconds * 1000);
console.log(date.toUTCString());
console.log(date.toISOString());
console.log(date.toLocaleDateString());

Convert milliseconds to date (Date.now() output):

const epochMilliseconds = Date.now();
const date = new Date(epochMilliseconds);
console.log(date.toUTCString());

Auto-detect seconds vs milliseconds:

function timestampToDate(ts) {
  const epochMs = ts.toString().length === 13 ? ts : ts * 1000;
  return new Date(epochMs);
}

console.log(timestampToDate(1783941653).toUTCString());
console.log(timestampToDate(1783941653000).toUTCString());

Format as a specific date string:

const epochSeconds = 1783941653;
const date = new Date(epochSeconds * 1000);
const formatted = date.toISOString().split('T')[0];
console.log(formatted);

How Do You Convert a Timestamp to a Date in Python?

Python's time.time() returns seconds as a float. Use datetime.utcfromtimestamp() for UTC output or datetime.fromtimestamp() for local time output.

Convert to UTC date (recommended):

import datetime

epoch_seconds = 1783941653
dt_utc = datetime.datetime.utcfromtimestamp(epoch_seconds)
print(dt_utc)

Convert to UTC with explicit timezone (best practice):

import datetime

epoch_seconds = 1783941653
dt = datetime.datetime.fromtimestamp(
    epoch_seconds,
    tz=datetime.timezone.utc
)
print(dt.strftime('%Y-%m-%d %H:%M:%S'))

Convert milliseconds to date:

import datetime

epoch_milliseconds = 1783941653000
epoch_seconds = epoch_milliseconds / 1000
dt_utc = datetime.datetime.utcfromtimestamp(epoch_seconds)
print(dt_utc)

Get current timestamp and convert back:

import time
import datetime

current = int(time.time())
dt = datetime.datetime.utcfromtimestamp(current)
print(f"Unix timestamp: {current}")
print(f"Readable date: {dt}")
Pro Tip:Always use datetime.utcfromtimestamp() or datetime.fromtimestamp(ts, tz=timezone.utc) in Python rather than datetime.fromtimestamp() without a timezone. The version without timezone uses the system's local timezone — producing different output depending on the server location, which causes subtle bugs that only appear in production across different hosting environments.

How Do You Convert a Timestamp to a Date in PHP?

PHP's date() function applies the server's local timezone — always use gmdate() for consistent UTC output.

Convert to UTC date string:

$epoch_seconds = 1783941653;
echo gmdate("Y-m-d H:i:s", $epoch_seconds);

Convert to formatted date with timezone:

$epoch_seconds = 1783941653;
$dt = new DateTime('@' . $epoch_seconds);
$dt->setTimezone(new DateTimeZone('UTC'));
echo $dt->format('Y-m-d H:i:s');

Convert milliseconds to date:

$epoch_milliseconds = 1783941653000;
$epoch_seconds = intval($epoch_milliseconds / 1000);
echo gmdate("Y-m-d H:i:s", $epoch_seconds);

Using DateTimeImmutable (recommended for new code):

$epoch_seconds = 1783941653;
$dt = new DateTimeImmutable('@' . $epoch_seconds);
echo $dt->format('Y-m-d H:i:s') . ' UTC';

How Do You Convert a Timestamp to a Date in SQL?

PostgreSQL:

SELECT TO_TIMESTAMP(1783941653);

SELECT TO_TIMESTAMP(1783941653) AT TIME ZONE 'UTC';

SELECT TO_CHAR(TO_TIMESTAMP(1783941653), 'YYYY-MM-DD HH24:MI:SS');

MySQL:

SELECT FROM_UNIXTIME(1783941653);

SELECT FROM_UNIXTIME(1783941653, '%Y-%m-%d %H:%i:%s');

SELECT CONVERT_TZ(FROM_UNIXTIME(1783941653), 'SYSTEM', 'UTC');

SQLite:

SELECT datetime(1783941653, 'unixepoch');

SELECT datetime(1783941653, 'unixepoch', 'localtime');

SQL Server:

SELECT DATEADD(SECOND, 1783941653, '1970-01-01');

How Do You Convert a Timestamp to a Date in Java?

Using Instant (Java 8+, recommended):

import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;

long epochSeconds = 1783941653L;
Instant instant = Instant.ofEpochSecond(epochSeconds);
String formatted = DateTimeFormatter.ISO_INSTANT.format(instant);
System.out.println(formatted);

Using LocalDateTime:

import java.time.LocalDateTime;
import java.time.ZoneOffset;

long epochSeconds = 1783941653L;
LocalDateTime dt = LocalDateTime.ofEpochSecond(
    epochSeconds, 0, ZoneOffset.UTC
);
System.out.println(dt);

Converting milliseconds:

import java.time.Instant;

long epochMilliseconds = 1783941653000L;
Instant instant = Instant.ofEpochMilli(epochMilliseconds);
System.out.println(instant);

How Do You Convert a Timestamp to a Date in Excel?

Excel does not natively understand Unix timestamps — it uses its own date serial number system starting from January 1, 1900. To convert a Unix timestamp in cell A1 to an Excel date:

Formula for seconds:

=(A1/86400)+25569

Then format the cell as a Date or Date/Time to display it correctly.

Formula for milliseconds:

=(A1/86400000)+25569

How the formula works:

  • Divide by 86400 (seconds per day) to convert seconds to days
  • Add 25569 (the number of days between January 1, 1900 and January 1, 1970)
  • Format the resulting cell as a Date or Date Time

For example, =(1783941653/86400)+25569 produces the Excel serial number for July 17, 2026.

How Do You Convert a Timestamp to a Date in Bash?

Linux (GNU date):

date -d @1783941653
date -d @1783941653 '+%Y-%m-%d %H:%M:%S'
date -d @1783941653 --utc '+%Y-%m-%d %H:%M:%S UTC'

macOS (BSD date):

date -r 1783941653
date -r 1783941653 '+%Y-%m-%d %H:%M:%S'

Convert milliseconds in Bash:

epoch_ms=1783941653000
epoch_s=$((epoch_ms / 1000))
date -d @$epoch_s '+%Y-%m-%d %H:%M:%S UTC'

How Do You Convert a Timestamp to a Date in Go?

package main

import (
    "fmt"
    "time"
)

func main() {
    epochSeconds := int64(1783941653)
    t := time.Unix(epochSeconds, 0).UTC()
    fmt.Println(t.Format("2006-01-02 15:04:05"))
}

How Do You Convert a Timestamp to a Date in Ruby?

epoch_seconds = 1783941653
time = Time.at(epoch_seconds).utc
puts time.strftime('%Y-%m-%d %H:%M:%S')

What Is the Timezone Trap When Converting Timestamps?

The most common real-world timestamp to date conversion bug is the timezone trap — conversion functions applying a local timezone instead of UTC without the developer noticing.

How it happens:

  • PHP's date() applies the server's local timezone — use gmdate() instead
  • Python's datetime.fromtimestamp() without a timezone argument uses the system local timezone — use datetime.utcfromtimestamp() or pass tz=timezone.utc
  • MySQL's FROM_UNIXTIME() converts to the server's local timezone — use CONVERT_TZ() to explicitly output UTC

The result: A timestamp stored in production in one timezone reads differently when the application moves to a new server, or when users in different locations view the same stored value.

The fix: Always convert to UTC at the data layer. Apply timezone conversion to local time only at the final display layer — and only when you know the user's timezone preference.

Timestamp to Date Quick Reference

LanguageSeconds to DateMilliseconds to Date
JavaScriptnew Date(ts * 1000).toUTCString()new Date(ts).toUTCString()
Pythondatetime.utcfromtimestamp(ts)datetime.utcfromtimestamp(ts/1000)
PHPgmdate('Y-m-d H:i:s', ts)gmdate('Y-m-d H:i:s', ts/1000)
JavaInstant.ofEpochSecond(ts)Instant.ofEpochMilli(ts)
SQL (PostgreSQL)TO_TIMESTAMP(ts)TO_TIMESTAMP(ts/1000)
SQL (MySQL)FROM_UNIXTIME(ts)FROM_UNIXTIME(ts/1000)
Bash (Linux)date -d @tsdate -d @$((ts/1000))
Gotime.Unix(ts, 0).UTC()time.UnixMilli(ts).UTC()
RubyTime.at(ts).utcTime.at(ts/1000.0).utc
Excel=(ts/86400)+25569=(ts/86400000)+25569

Common Mistakes to Avoid

  • Using a 13-digit milliseconds value where 10-digit seconds are expected. The output shows a date in the year 56,000. Always check digit count — 10 = seconds, 13 = milliseconds. Divide by 1,000.
  • Forgetting to multiply by 1,000 in JavaScript. new Date(epochSeconds) requires milliseconds — always use new Date(epochSeconds * 1000) when your input is in seconds.
  • Using date() instead of gmdate() in PHP. date() applies the server's local timezone — use gmdate() for consistent UTC output across all server environments.
  • Using datetime.fromtimestamp() without timezone in Python. Without an explicit timezone argument, this function uses the system local timezone — producing output that varies by server location.
  • Not formatting the cell in Excel. After applying the formula =(ts/86400)+25569 the cell displays a decimal number until you format it as a Date or Date/Time cell type.
  • Storing local time in the database. Always store the raw Unix timestamp or a UTC date string — never a local time value. Apply timezone conversion only at the display layer.

Related Guides

Convert any timestamp to a date instantly with the Unix Timestamp Converter, or generate a Discord timestamp from any date with the Discord Timestamp Generator.

Frequently Asked Questions

Check the digit count first — 10 digits means seconds, 13 digits means milliseconds (divide by 1,000). Then use your language's built-in function: JavaScript new Date(seconds * 1000).toUTCString(), Python datetime.utcfromtimestamp(seconds), PHP gmdate('Y-m-d H:i:s', seconds). For instant conversion without code use the [Unix Timestamp Converter](/unix-timestamp-converter).
A 13-digit timestamp is in milliseconds — 1,000 times larger than a standard 10-digit Unix timestamp in seconds. JavaScript's Date.now() and Java's System.currentTimeMillis() return 13-digit millisecond timestamps. Divide by 1,000 to convert to a standard 10-digit seconds timestamp before using in most APIs, databases, or Discord timestamp codes.
In JavaScript: new Date(unixTimestamp * 1000).toUTCString(). In Python: datetime.utcfromtimestamp(unixTimestamp). In PHP: gmdate('Y-m-d H:i:s', unixTimestamp). In SQL: TO_TIMESTAMP(unixTimestamp) in PostgreSQL or FROM_UNIXTIME(unixTimestamp) in MySQL. For no-code conversion use the [Unix Timestamp Converter](/unix-timestamp-converter).
A Unix timestamp is calculated by counting the total number of seconds elapsed since January 1 1970 at 00:00:00 UTC (the Unix epoch). Every second that passes increments the value by exactly 1. The current value in mid-2026 is approximately 1,784,000,000. Converting back to a date reverses this calculation by adding the counted seconds to the epoch reference point.
In JavaScript use new Date(epochSeconds * 1000) — the Date constructor expects milliseconds, so multiply seconds by 1,000. For UTC output call .toUTCString() or .toISOString(). For local time output call .toLocaleDateString(). If your timestamp is already in milliseconds (13 digits from Date.now()), pass it directly: new Date(epochMilliseconds).
In Python use datetime.datetime.utcfromtimestamp(epoch_seconds) for UTC output. For explicit timezone handling use datetime.datetime.fromtimestamp(epoch_seconds, tz=datetime.timezone.utc). For milliseconds divide by 1,000 first: datetime.datetime.utcfromtimestamp(epoch_milliseconds / 1000). Always specify UTC explicitly to avoid server timezone inconsistencies.
In PHP use gmdate("Y-m-d H:i:s", $epoch_seconds) for UTC output — never use date() which applies the server's local timezone. For milliseconds divide first: gmdate("Y-m-d H:i:s", intval($epoch_ms / 1000)). For object-oriented code use new DateTimeImmutable('@' . $epoch_seconds).
In PostgreSQL use TO_TIMESTAMP(epoch_seconds). In MySQL use FROM_UNIXTIME(epoch_seconds). In SQLite use datetime(epoch_seconds, 'unixepoch'). In SQL Server use DATEADD(SECOND, epoch_seconds, '1970-01-01'). For milliseconds divide by 1,000 in the function argument.
Use the formula =(A1/86400)+25569 where A1 contains your Unix timestamp in seconds. Then format the cell as Date or Date/Time. For milliseconds use =(A1/86400000)+25569. The formula converts seconds to days and adds the offset between Excel's epoch (January 1, 1900) and the Unix epoch (January 1, 1970).

Ready to generate Discord timestamps?

Open the Generator

Did You Miss These?

Discord Guide

Generate a Discord Timestamp

Free tool — all 7 formats, live Discord preview, auto timezone detection.

Open Generator →
Discord Guide8 min read

Jun 29, 2026

Unix Timestamp to Date — Complete Guide

How to convert a Unix timestamp to a human readable date in JavaScript, Python, PHP, Java, MySQL and more. Code examples and common mistakes covered.

Read Article →
Discord Guide8 min read

Jun 29, 2026

Unix Timestamp to Date — Complete Guide

How to convert a Unix timestamp to a human readable date in JavaScript, Python, PHP, Java, MySQL and more.

Read Article →
Discord Guide11 min read

Jul 17, 2026

Unix Timestamp — Complete Guide to Epoch Time and How It Works

A Unix timestamp is a single integer counting seconds since January 1 1970 UTC. Complete guide covering format, precision levels, code examples in every language, and the Year 2038 problem.

Read Article →
Discord Guide12 min read

Jul 17, 2026

Discord Timestamp — The Complete Guide to All 7 Formats

Everything about Discord timestamps — all 7 format codes, the syntax, how to generate codes, the @time feature, troubleshooting, and why timestamps beat manual timezone conversion.

Read Article →