Last updated
Why Convert Twitter ID to Timestamp?
- Database Storage: Store timestamps in Unix format for efficient querying
- API Integration: Many APIs require Unix timestamps
- Data Analysis: Analyze Twitter data using timestamp calculations
- Sorting & Filtering: Sort tweets chronologically using timestamps
- Time Calculations: Calculate time differences between tweets
Example Conversions
ID: 1382350606417817604
Timestamp: 1618414206417 ms (1618414206 seconds)
Twitter ID to Timestamp Converter — Examples
The Twitter ID to Timestamp Converter extracts the creation timestamp from any Twitter Snowflake ID. Every Twitter ID encodes the exact millisecond of creation in its structure. Here are practical examples covering all common use cases.
Core Conversion Function
// JavaScript — full Snowflake decoder
function decodeSnowflake(idStr) {
const id = BigInt(idStr);
const twitterEpoch = 1288834974657n;
const timestampMs = (id >> 22n) + twitterEpoch;
const datacenterId = Number((id >> 17n) & 0x1Fn);
const workerId = Number((id >> 12n) & 0x1Fn);
const sequence = Number(id & 0xFFFn);
const date = new Date(Number(timestampMs));
return {
id: idStr,
timestampMs: timestampMs.toString(),
unixSeconds: Math.floor(Number(timestampMs) / 1000),
utc: date.toUTCString(),
iso8601: date.toISOString(),
datacenterId,
workerId,
sequence
};
}
// Example
console.log(decodeSnowflake("1529877576591609861"));
# Python — full Snowflake decoder
from datetime import datetime, timezone
def decode_snowflake(id_str):
id_val = int(id_str)
twitter_epoch_ms = 1288834974657
timestamp_ms = (id_val >> 22) + twitter_epoch_ms
datacenter_id = (id_val >> 17) & 0x1F
worker_id = (id_val >> 12) & 0x1F
sequence = id_val & 0xFFF
dt = datetime.fromtimestamp(timestamp_ms / 1000, tz=timezone.utc)
return {
"id": id_str,
"timestamp_ms": timestamp_ms,
"unix_seconds": timestamp_ms // 1000,
"utc": dt.strftime("%Y-%m-%d %H:%M:%S UTC"),
"iso8601": dt.isoformat(),
"datacenter_id": datacenter_id,
"worker_id": worker_id,
"sequence": sequence
}
print(decode_snowflake("1529877576591609861"))
Multiple Output Formats
// Display timestamp in all common formats
function allFormats(idStr) {
const id = BigInt(idStr);
const twitterEpoch = 1288834974657n;
const tsMs = (id >> 22n) + twitterEpoch;
const date = new Date(Number(tsMs));
return {
utc: date.toUTCString(),
iso8601: date.toISOString(),
unixMs: tsMs.toString(),
unixSeconds: Math.floor(Number(tsMs) / 1000),
localTime: date.toLocaleString(),
dateOnly: date.toISOString().split("T")[0],
timeOnly: date.toISOString().split("T")[1].replace("Z", " UTC")
};
}
const formats = allFormats("1529877576591609861");
Object.entries(formats).forEach(([key, val]) => {
console.log(`${key.padEnd(12)}: ${val}`);
});
Batch Conversion
# Python — batch convert a list of IDs to timestamps
import csv
from datetime import datetime, timezone
def decode_id(id_val):
ts_ms = (id_val >> 22) + 1288834974657
return datetime.fromtimestamp(ts_ms / 1000, tz=timezone.utc)
# Input: list of tweet IDs
tweet_ids = [
"1529877576591609861",
"1700000000000000000",
"1800000000000000000",
"1900000000000000000",
"2024288437327843509",
]
# Output: CSV with ID and timestamp
with open("tweet_timestamps.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["tweet_id", "created_at_utc", "unix_timestamp"])
for id_str in tweet_ids:
dt = decode_id(int(id_str))
writer.writerow([id_str, dt.isoformat(), dt.timestamp()])
print("Exported tweet_timestamps.csv")
Java Implementation
// Java — decode Twitter Snowflake ID
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
public class TwitterSnowflake {
private static final long TWITTER_EPOCH = 1288834974657L;
public static ZonedDateTime decode(long id) {
long timestampMs = (id >> 22) + TWITTER_EPOCH;
return ZonedDateTime.ofInstant(
Instant.ofEpochMilli(timestampMs),
ZoneOffset.UTC
);
}
public static void main(String[] args) {
long tweetId = 1529877576591609861L;
ZonedDateTime date = decode(tweetId);
System.out.println("UTC: " + date.format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
System.out.println("Unix (s): " + date.toEpochSecond());
// Component breakdown
int datacenterId = (int)((tweetId >> 17) & 0x1F);
int workerId = (int)((tweetId >> 12) & 0x1F);
int sequence = (int)(tweetId & 0xFFF);
System.out.println("Datacenter: " + datacenterId);
System.out.println("Worker: " + workerId);
System.out.println("Sequence: " + sequence);
}
}
Reverse Conversion: Date to Snowflake ID
// JavaScript — convert a date to the minimum Snowflake ID for that moment
function dateToMinSnowflakeId(date) {
const twitterEpoch = 1288834974657n;
const tsMs = BigInt(date.getTime()) - twitterEpoch;
return (tsMs << 22n).toString(); // sequence, worker, datacenter = 0
}
function dateToMaxSnowflakeId(date) {
const twitterEpoch = 1288834974657n;
const tsMs = BigInt(date.getTime()) - twitterEpoch;
// Max: all lower 22 bits set to 1
return ((tsMs << 22n) | 0x3FFFFFn).toString();
}
// Get ID range for a specific date
const date = new Date("2023-06-01T00:00:00Z");
console.log("Min ID:", dateToMinSnowflakeId(date));
console.log("Max ID:", dateToMaxSnowflakeId(date));
Using Timestamps for API Pagination
# Use decoded timestamps to understand API pagination
import requests
from datetime import datetime, timezone
TWITTER_EPOCH_MS = 1288834974657
def id_to_datetime(id_str):
id_val = int(id_str)
ts_ms = (id_val >> 22) + TWITTER_EPOCH_MS
return datetime.fromtimestamp(ts_ms / 1000, tz=timezone.utc)
def datetime_to_min_id(dt):
ts_ms = int(dt.timestamp() * 1000) - TWITTER_EPOCH_MS
return str(ts_ms << 22)
# Fetch tweets from a specific time window
start = datetime(2023, 1, 1, tzinfo=timezone.utc)
end = datetime(2023, 1, 2, tzinfo=timezone.utc)
since_id = datetime_to_min_id(start)
max_id = datetime_to_min_id(end)
print(f"Fetching tweets between {start.date()} and {end.date()}")
print(f"since_id: {since_id}")
print(f"max_id: {max_id}")
Handling Edge Cases
- Pre-Snowflake IDs (before Nov 2010): cannot be decoded — they don't contain timestamps
- JavaScript precision: always use BigInt or string representation for IDs
- Timezone display: the timestamp is always UTC; convert to local time as needed
- Tweet vs user IDs: both use the same Snowflake format and decode identically
The Twitter ID to Timestamp Converter handles all these cases and provides accurate millisecond-precision timestamps for any valid Snowflake ID.
ID: 1800000000000000000
Timestamp: 1720612800000 ms (1720612800 seconds)
How to Use This Converter
1. Enter any Twitter ID (tweet ID, user ID, etc.)
2. Click "Convert to Timestamp"
3. Get Unix timestamp in both milliseconds and seconds
4. Use the timestamp in your applications or databases
Frequently Asked Questions
Yes, our Twitter Id To Timestamp Converter is completely free with no registration required. Use it unlimited times without any restrictions.
Yes, all processing happens locally in your browser. Your data never leaves your device and is not stored on our servers.
No installation needed. The tool works directly in your web browser on any device.
The tool supports all standard formats. Simply paste your input and the conversion happens instantly.
Yes, you can process multiple conversions by using the tool repeatedly. Each conversion is instant.