formatISO
WARNING
formatISO is a date-fns helper, not a fedaco function. It appears in fedaco test fixtures because the e2e tests pin timestamps via formatISO(startOfSecond(now)).
What it does
Formats a Date into an ISO-8601 string. Used in tests to assert that fedaco serialises timestamps consistently.
ts
import { formatISO, startOfSecond } from 'date-fns';
const now = new Date();
const reference = formatISO(startOfSecond(now)); // 2026-05-07T10:23:42+00:00Why it shows up in fedaco docs
Several model assertions compare a serialised Date against formatISO(startOfSecond(now)) rather than now.toISOString(), because:
- SQLite truncates fractional seconds depending on the column type.
startOfSecond(now)discards milliseconds before formatting, so the assertion holds regardless.
Real-World Use Cases (in your own code)
You typically don't need this — fedaco serialises model dates via the connection grammar's getDateFormat. If you're doing manual comparisons in tests:
ts
import { formatISO, startOfSecond } from 'date-fns';
const post = await Post.createQuery().create({ published_at: now });
expect(post.published_at).toEqual(startOfSecond(now));
// or, comparing serialised forms:
expect(formatISO(post.published_at)).toBe(formatISO(startOfSecond(now)));For producing serialised dates from a fedaco model, see the model's toArray output — date columns are formatted via serializeDate.
See Also
- date-fns
formatISOdocs startOfSecond— also from date-fns; discards fractional seconds.fromDateTime/setDateFormat— fedaco's own date handling.toArray— how fedaco serialises models for output.