What this Timestamp Converter converts
Timestamp Converter maps a numeric Unix instant to display strings, or maps a datetime-local civil time to Unix numbers, using the browser Date API. The page opens in Timestamp to Date with an empty Unix field, unit Auto-detect, and no result. Date to Timestamp starts with getNowLocalDateTimeValue() (local year-month-day and hour:minute). There is no file picker and no Clear button.
The Current time panel is separate: every second it shows Math.floor(Date.now()/1000), Date.now(), formatUtc(now), and toLocaleString(now), with Copy seconds / Copy milliseconds. That clock is not a network time source.
Unix seconds versus milliseconds in this tool
- Seconds
- Treats the number as seconds: milliseconds = numeric * 1000, then new Date(milliseconds).
- Milliseconds
- Passes the number to new Date(numeric) as milliseconds.
- Auto-detect
- detectUnit on integers only; length ≥ 13 or |n| > 9,999,999,999 → milliseconds, else seconds.
Outputs unixSeconds and unixMilliseconds use Math.trunc (seconds = trunc(ms/1000)). A decimal input can therefore show truncated integers. The “JavaScript milliseconds” example forces Milliseconds; other timestamp examples leave Auto-detect. Use current time forces Seconds.
UTC, browser-local time, and formatted output
formatUtc builds YYYY-MM-DD HH:MM:SS UTC from getUTC* getters. formatLocal is date.toLocaleString() with no locale or timeZone options, so the string follows this browser’s locale and host zone. formatIso is date.toISOString() (always a UTC Z string). Relative time uses Intl.RelativeTimeFormat("en", { numeric: "auto" }) with coarse buckets (seconds → years via 60 / 60 / 24 / 30 / 365).
In Date to Timestamp, Local time constructs new Date(year, month - 1, day, hours, minutes) (seconds 0). UTC constructs Date.UTC(...) the same way. The sidebar Timezone label is “UTC storage” in timestamp mode, or “UTC” / “Local” in date mode. Copy on a result row copies that exact display string, not a hidden canonical object.
How the real inputs and controls behave
- Current time shows live Unix seconds, Unix milliseconds, UTC time, and Local time from Date.now() every 1000 ms. Copy seconds and Copy milliseconds write those live values via navigator.clipboard.writeText.
- Click Timestamp to Date or Date to Timestamp in the Conversion mode group. handleModeChange clears error, copied, and Conversion result; the Unix timestamp and Date and time fields stay.
- In Timestamp to Date, paste into Unix timestamp (placeholder 1703123456). Click Auto-detect (default), Seconds, or Milliseconds. Those OptionToggle clicks only set unitMode; click Convert timestamp after changing them.
- Click Convert timestamp. It stays disabled while Unix timestamp is blank or whitespace-only. Empty runTimestampConversion throws “Enter a Unix timestamp to convert.”
- In Date to Timestamp, set Date and time (input type datetime-local). Click Local time (default) or UTC. Those toggles only set useUtc; click Convert date after changing them.
- Click Convert date. parseDateInput splits on T, defaults missing time to 00:00, and reads only hours and minutes (a seconds fragment is ignored). Empty throws “Select a date and time to convert.”
- Conversion result lists Unix seconds, Unix milliseconds, UTC time, Local time, ISO 8601, and Relative time, each with Copy (Copied for 1.5 seconds). Empty state copy is “Conversion results will appear here.” There is no download and no Clear.
- Click Use current time to switch to Timestamp to Date, fill live Unix seconds, set Seconds, and convert immediately.
- Click a Quick examples row: Current time (live seconds, Auto-detect), Unix epoch (“0”, Auto-detect), JavaScript milliseconds (“1703123456789”, Milliseconds), API timestamp (“1703123456”, Auto-detect), or Log timestamp (“2024-12-21T14:30”, Date to Timestamp with Local time). Each converts immediately.
Invalid, ambiguous, fractional, negative, and large timestamp values
- Empty Unix field: “Enter a Unix timestamp to convert.” Non-numeric: “Enter a valid numeric Unix timestamp.”
- Auto-detect on a decimal: “Could not detect seconds or milliseconds.”
- new Date(ms) with NaN getTime: “Timestamp is out of range.”
- Empty datetime-local: “Select a date and time to convert.” Unparseable parts: “Enter a valid date and time.”
- Negative integers are allowed by the numeric regex and detectUnit (pre-1970 instants if Date accepts them).
- JavaScript Date overflow (for example an out-of-range day) can still yield a valid getTime; Valid date Yes is not calendar validation.
Date conversion versus time-zone conversion or event scheduling
This page does not list IANA zones, does not query a time-zone database, and does not schedule events. Showing Local time is a display of the same instant through toLocaleString / the host Date constructor, not a conversion from “America/New_York” to “Europe/London.” DST at the host may affect how a local civil time is constructed, but you cannot select or verify a named zone’s DST rule here.
A converted number does not prove a business date, meeting time, or JWT expiry decision. JWT Decoder treats iat and exp as Unix seconds (new Date(value * 1000) then toLocaleString). If your value is milliseconds, that decoder’s date line will be wrong; convert with an explicit unit here first.
How to review a converted value
- Confirm Seconds vs Milliseconds vs Auto-detect before trusting the calendar date.
- If you toggled a unit or Local/UTC after a run, convert again; those toggles do not re-run.
- Compare UTC time (fixed UTC getters) with Local time (host toLocaleString)—they are different presentations of one Date.
- ISO 8601 here means toISOString(), not a parser for arbitrary ISO input in Timestamp to Date.
- Relative time is a snapshot; the live clock is the panel at the top.
Privacy and browser-processing boundaries
TimestampConverter.jsx uses Date, Date.UTC, toISOString, toLocaleString, and Intl.RelativeTimeFormat in the browser. It does not call trackToolEvent and does not POST the timestamp to a conversion API. That is not a confidentiality guarantee: the rest of the page can still load site assets and advertising; the privacy policy describes first-party analytics for event metadata (not designed to store tool contents); clipboard, extensions, and shared devices remain outside this file.
Do not treat the live clock as authoritative legal time. Date.now() is the browser’s clock.
A short timestamp-checklist
- Pick the unit explicitly when the scale is known; Auto-detect is an integer heuristic.
- Remember datetime-local has no seconds in this parser.
- Do not assume toLocaleString matches another computer’s locale or zone.
- Do not assume Valid date Yes means a real calendar date was validated.
- There is no download and no Clear; copy the row you need, or switch mode to drop the result panel.
When another DevToolKit tool is more appropriate
- Time Zone Converter — when you need a named IANA city zone, UTC offsets, or DST-aware city comparison. This page has no zone list.
- JWT Decoder — when the number is an iat or exp claim on a token. That decoder already formats those claims as Unix seconds; it does not open this converter.