# FIX Timestamp Reader

Industry: Finance

**Key point — FIX UTCTimestamp values**

The number of digits is a fact about the measurement. A stamp with three fraction digits says the clock was read to the millisecond, and nothing finer exists to be recovered.

A FIX `SendingTime` (52) or `TransactTime` (60) is a `UTCTimestamp`: `YYYYMMDD-HH:MM:SS`, then nothing or a period and 3, 6, 9 or 12 digits. Paste one and the tool says what it states. [`parseFixUtcTimestamp`](/gmt/reference/finance/parse/parseFixUtcTimestamp/) reads it into an instant and a precision, [`isValidFixUtcTimestamp`](/gmt/reference/finance/validate/isValidFixUtcTimestamp/) says whether it is one, and everything on the page is what those calls returned. A second section goes the other way with [`formatFixUtcTimestamp`](/gmt/reference/finance/format/formatFixUtcTimestamp/).

**The precision is the digit count.** FIX names four fraction widths: milliseconds (3 digits), microseconds (6), nanoseconds (9) and picoseconds (12). A stamp with no fraction is read to the second. The tool draws each run of digits in its own bracket and shows a run that was not sent as a dashed box, so a `.100` stamp lights one run and leaves three empty. Reading `.100` as a nanosecond count is the mistake in [A millisecond stamp read as nanoseconds](/gmt/scenarios/a-millisecond-stamp-read-as-nanoseconds/).

**Picoseconds are held apart.** An instant here holds nine fraction digits, so the last three digits of a 12-digit stamp are returned as `picoseconds` and kept off the instant. A stamp that sent them as `000` and a stamp that sent none both report `picoseconds` as `0`, so the plate shows digits only at picosecond precision and says "none sent" everywhere else. It never shows `0` for digits that were not sent.

**Second 60.** FIX allows a second of 60 only for a leap second UTC really inserted. UTC has inserted 27 since 1972, the last at the end of 2016, and none has been scheduled since. So `20161231-23:59:60.500` is the half second into the one UTC added, and `20171231-23:59:60` is refused: that day had no second 60. Many systems check the spelling and store the second before it; that is [Second sixty on an ordinary day](/gmt/scenarios/second-sixty-on-an-ordinary-day/). When a stamp is refused, the sentence under the verdict comes from asking the library again: with the 60 changed to 59, then the same day at 23:59:60, then with the fraction removed, then one general sentence. The 23:59:60 probe tells a 60 at the wrong minute from a 60 on a day with no leap second. The tool holds no FIX grammar, width table or leap-second table.

**Writing an instant.** The second section writes one instant at all five precisions. A narrower precision cuts the extra digits and does not round, so `23:59:59.999600` written to the millisecond is `23:59:59.999`, not the next second. The picosecond row is padded with `000`: the instant holds nothing finer. A local time with no Z or offset is refused with the sentinel, because it names no instant. The button copies the instant read in section 2, so a leap second round-trips.

```ts
import { parseFixUtcTimestamp } from "@northguild/gmt/finance/parse";
import { formatFixUtcTimestamp } from "@northguild/gmt/finance/format";
import { isValidFixUtcTimestamp } from "@northguild/gmt/finance/validate";

isValidFixUtcTimestamp("20161231-23:59:60.500"); // true
isValidFixUtcTimestamp("20171231-23:59:60"); // false
parseFixUtcTimestamp("20240615-14:30:00.100")?.precision; // "millisecond"
formatFixUtcTimestamp("2024-12-31T23:59:59.999600Z", "millisecond"); // "20241231-23:59:59.999"
formatFixUtcTimestamp("2016-12-31T23:59:60.5Z", "millisecond"); // "20161231-23:59:60.500"
```

**Worth trying:** [a millisecond stamp](/gmt/tools/fix-timestamp-reader/?w=fixstamp&wa=%7B%22stamp%22%3A%2220240615-14%3A30%3A00.100%22%7D) lights one run of three; [the 2016 leap second](/gmt/tools/fix-timestamp-reader/?w=fixstamp&wa=%7B%22stamp%22%3A%2220161231-23%3A59%3A60.500%22%7D) reads as inserted; then [the same second on an ordinary day](/gmt/tools/fix-timestamp-reader/?w=fixstamp&wa=%7B%22stamp%22%3A%2220171231-23%3A59%3A60%22%7D) and read the reason. The [Leap Second Timeline](/gmt/tools/leap-second-timeline/) lists every second UTC inserted, and the [ID Timestamp Decoder](/gmt/tools/id-timestamp-decoder/) reads the timestamps inside identifiers. The rules are in [Finance: Message Timestamps](/gmt/guides/industries/finance-message-timestamps/), and the mistakes around them are in [Finance mistakes](/gmt/mistakes/finance/).
