Dyrected
Model ContentFields

Date

A field for dates and times, stored as an ISO string and shown with a picker.

The date field stores a calendar day and shows editors a date picker. Dates cross the API as ISO strings, so parse them at your application boundary when you need to do date arithmetic. When you also need a time, reach for Datetime; for a time of day on its own, use Time.

defineDateField({ name: 'publishedAt', label: 'Published at' })

Dates are often sorted and filtered on — a publishedAt you order posts by, for instance. If you query a date field often, mark it promoted so it becomes an indexed column. See Database indexes.

Formatting how the date displays

By default a date renders as a plain calendar date in the admin list. Set admin.format when you want a different style, or when a relative date like "3 days ago" reads better than an exact one:

defineDateField({ name: 'publishedAt', label: 'Published at', admin: { format: 'relative' } })

For a specific style, pass an object with a dateStyle:

defineDateField({
  name: 'publishedAt',
  label: 'Published at',
  admin: { format: { type: 'date', dateStyle: 'long' } },
})

dateStyle accepts 'short', 'medium', 'long', or 'full', matching how you'd choose a length when writing a date by hand. Add a locale (a BCP 47 tag like 'en-GB') to pin the formatting; leave it off to follow the viewer's browser locale.

Formatting is display-only — the value is still stored and returned as an ISO string, so your frontend keeps full control over how the date appears on the site.

Generated reference

The contract below is generated from the public @dyrected/core exports by @dyrected/knowledge, so it stays in sync with the package. See Fields for the shared field options every type accepts.

DateField

A calendar day, stored and returned as an ISO date string.

export type DateField = TypedField<"date", string, DateFieldAdmin>;

DateFieldAdmin

Exported type from @dyrected/core.

export type DateFieldAdmin = {
  /** How the value is displayed in read-only Admin surfaces (list cells, read-only inputs). Does not affect storage or editing. */
  format?: DateFormat;
};

DateFormat

How a date, datetime, or time field's value is presented in read-only Admin surfaces. Display only and JSON-serializable so it round-trips through Dyrected Cloud.

Pass a shorthand string (format: "relative") or an object for finer control (format: { type: "date", dateStyle: "long" }).

export type DateFormat =
  /** Shorthand for the matching object form, using that format's defaults. */
  | "date"
  | "datetime"
  | "time"
  | "relative"
  /** Calendar date, e.g. `Jan 5, 2026`. */
  | {
      type: "date";
      dateStyle?: "short" | "medium" | "long" | "full";
      /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
      locale?: string;
    }
  /** Date and time together, e.g. `Jan 5, 2026, 2:30 PM`. */
  | {
      type: "datetime";
      dateStyle?: "short" | "medium" | "long" | "full";
      timeStyle?: "short" | "medium" | "long" | "full";
      /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
      locale?: string;
    }
  /** Time of day, e.g. `2:30 PM`. */
  | {
      type: "time";
      timeStyle?: "short" | "medium" | "long" | "full";
      /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
      locale?: string;
    }
  /** Relative to now, e.g. `3 days ago`, `in 2 hours`. */
  | {
      type: "relative";
      /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
      locale?: string;
    };

On this page

Dyrected| Cloud

Get your backend ready in minutes

Use a managed database, storage, APIs, and admin dashboard without setting up the infrastructure yourself.

Set Up My Backend