Some systems represent Unix timestamps as hexadecimal — typical in binary protocols, low-level debugging, hex dumps, and forensics. This converter goes between hex, decimal, and human-readable dates.
A Unix hex timestamp is just a standard Unix timestamp (seconds since 1970-01-01 UTC) written in hexadecimal instead of decimal. There's no separate "hex format" — it's the same value, different base.
You'll encounter hex timestamps in:
| Decimal | Hex | Date |
|---|---|---|
0 | 0x00000000 | 1970-01-01 00:00:00 UTC |
946684800 | 0x386D4380 | 2000-01-01 00:00:00 UTC |
1735689600 | 0x67742800 | 2025-01-01 00:00:00 UTC |
2147483647 | 0x7FFFFFFF | 2038-01-19 03:14:07 UTC (Y2038!) |
When extracting timestamps from binary files or network packets, you need to know the byte order (endianness):
1735689600 (2025-01-01 UTC) → bytes: 67 74 28 00
1735689600 (2025-01-01 UTC) → bytes: 00 28 74 67
If you see what looks like a date but it's converting to an impossible value, try byte-swapping it.
unix_seconds = parseInt(hex_string, 16)
hex_string = unix_seconds.toString(16)
// Hex to date (handles both "0x..." and bare hex)
function hexToDate(hex) {
const clean = hex.toLowerCase().replace(/^0x/, '');
const sec = parseInt(clean, 16);
return new Date(sec * 1000);
}
// Date to hex (8-character zero-padded)
function dateToHex(date) {
const sec = Math.floor(date.getTime() / 1000);
return '0x' + sec.toString(16).padStart(8, '0');
}
// Swap byte order (big-endian ↔ little-endian)
function swapBytes(hex) {
const clean = hex.replace(/^0x/, '').padStart(8, '0');
return clean.match(/.{2}/g).reverse().join('');
}
def hex_to_unix(hex_str: str) -> int:
return int(hex_str.lstrip('0x'), 16)
def unix_to_hex(unix_sec: int) -> str:
return format(unix_sec, '08x')
# Byte-swap (4-byte big-endian to little-endian and vice versa)
def swap_bytes(hex_str: str) -> str:
h = hex_str.lstrip('0x').zfill(8)
return ''.join(reversed([h[i:i+2] for i in range(0, len(h), 2)]))
# Hex to date
echo "67742800" | xargs -I {} printf "%d\n" 0x{} | xargs -I {} date -u -d @{}
# Date to hex
printf "%x\n" $(date +%s)