Back to Blog
Developers

Slack ts to Datetime: Convert Message Timestamps in Python, JavaScript and SQL

A Slack ts such as 1794540033.531219 is Unix seconds plus a 6-digit sequence. We converted real ts values in Python, JavaScript and SQLite, and found that rounding to 15 digits, as spreadsheets do, makes chat.update answer message_not_found.

Slack Green Team
November 13, 2026
November 13, 2026
3 min read
Share:
slack
slack api

A Slack message ts such as 1794540033.531219 is the Unix time in seconds, a dot, and 6 more digits. The part before the dot converts to a date like any Unix timestamp: 1794540033.531219 is 13 November 2026, 03:20:33 UTC. The ts is also the message's ID, so keep the original string for API calls and convert a copy for display. On 13 November 2026 we read real ts values from conversations.history in a test workspace and converted them in Python, JavaScript and SQLite.

Python

# ts.py, run as: python3 ts.py 1794540033.531219
import sys
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
ts = sys.argv[1]
dt = datetime.fromtimestamp(float(ts), tz=timezone.utc)
print("float(ts):        ", float(ts))
print("UTC datetime:     ", dt.isoformat())
print("New York:         ", dt.astimezone(ZoneInfo("America/New_York")).isoformat())
sec, micro = ts.split(".")
exact = datetime.fromtimestamp(int(sec), tz=timezone.utc).replace(microsecond=int(micro))
print("exact from string:", exact.isoformat())
print("back to ts:       ", f"{int(exact.timestamp())}.{exact.microsecond:06d}")

Output (Python 3, macOS):

float(ts):         1794540033.531219
UTC datetime:      2026-11-13T03:20:33.531219+00:00
New York:          2026-11-12T22:20:33.531219-05:00
exact from string: 2026-11-13T03:20:33.531219+00:00
back to ts:        1794540033.531219

The round trip gives back the same string, so you can store a datetime and rebuild the ts if you keep all 6 digits.

JavaScript

// ts.mjs, run as: node ts.mjs 1794540033.531219
const ts = process.argv[2];
const d = new Date(Number(ts) * 1000);
console.log("Number(ts):      ", Number(ts));
console.log("toISOString():   ", d.toISOString());
const [sec, micro] = ts.split(".");
console.log("BigInt micros:   ", (BigInt(sec) * 1000000n + BigInt(micro)).toString());
console.log("parseFloat to 15:", parseFloat(ts).toPrecision(15));
console.log("en-US New York:  ", d.toLocaleString("en-US", { timeZone: "America/New_York" }));

Output (Node.js 26):

Number(ts):       1794540033.531219
toISOString():    2026-11-13T03:20:33.531Z
BigInt micros:    1794540033531219
parseFloat to 15: 1794540033.53122
en-US New York:   11/12/2026, 10:20:33 PM

A JavaScript Date keeps milliseconds only, so .531219 becomes .531Z. That is fine for display. Never build a ts back from a Date.

SQL (SQLite)

SELECT ts,
       datetime(CAST(ts AS REAL), 'unixepoch')                      AS utc_second,
       strftime('%Y-%m-%d %H:%M:%f', CAST(ts AS REAL), 'unixepoch') AS utc_ms
FROM messages;
-- a message posted at 03:20:43 UTC
1794540043.229969 | 2026-11-13 03:20:43 | 2026-11-13 03:20:43.230

Store the ts column as text, and cast only in the query. A REAL column sorts correctly, but you would have to format it back to exactly 6 decimals before every API call.

Never appear "away" on Slack again

Cloud-based. No downloads. Works 24/7 even when your laptop is off.

The precision trap

A double-precision float holds a current ts exactly: all 53 values we read came back unchanged through Python's float and JavaScript's Number. The problem is tools that keep 15 significant digits, such as spreadsheets and some JSON or CSV exporters. A ts has 16 digits, so 1794540033.531219 becomes 1794540033.53122. We sent both to the API:

Callts sentAnswer
chat.update1794540033.531219ok
chat.update1794540033.53122message_not_found
conversations.replies1794540033.53122thread_not_found

So if a script reads message IDs from a spreadsheet or a CSV opened in Excel and suddenly gets message_not_found, check whether the last digit is gone. Format the column as text before you paste. The same rule applies to thread_ts, which is just the parent message's ts; see our thread_ts guide.

One more pattern from our data: every one of the 53 ts values ended in the digit 9. We would not rely on that, but it means a trailing zero is rare, and the precision bugs you will meet are rounding, not lost zeros.

Turn a date into a ts for the API

conversations.history takes oldest and latest as ts strings. Any Unix time works there, so the start of a day is enough:

from datetime import datetime, timezone
oldest = str(datetime(2026, 11, 13, tzinfo=timezone.utc).timestamp())  # "1794528000.0"

To show a date to users inside a Slack message instead, use Slack's <!date^1794540033^{date_short} at {time}|fallback> syntax, which our Slack timestamp tool builds for you.

FAQ

Is the ts unique?

Within one channel, yes; Slack uses channel plus ts as the message's key. Two channels can hold messages with the same ts, so store both.

Does the ts change when a message is edited?

No. An edit keeps the ts and adds an edited object with its own ts, which is what our chat.update guide and edited messages test rely on.

Always Active

Stop Jiggling Your Mouse.

Join hundreds of remote workers who never worry about their Slack status. Set it up once, stay green forever.

Related Articles

Developers

Slack App Configuration Token: Generate, Rotate and Revoke

An app configuration token lets a script create Slack apps from manifests. We generated one, rotated it five times and tested it again 28 hours later.

Slack Green Team
Developers

Slack App Collaborators: Add, Remove and Transfer Ownership

Collaborators are the people who can edit a Slack app. We added and removed one on 20 November 2026 as a regular member of a test workspace, recorded who can be added and what Slack asks you to do after a removal, and wrote down the hand-over path Slack documents.

Slack Green Team
Developers

Slack Bolt Middleware: Global and Listener, Tested

Global middleware runs for every request and listener middleware for one listener. We ran both in Bolt for Python and Bolt for JavaScript on 20 November 2026 and logged what Slack did when next() was skipped: Python answered 404 and Slack sent the event again.

Slack Green Team