Date

This article explains what the date field is and how to configure it.

The date field allows content writers to select a date that represents a calendar day.

The date is saved in YYYY-MM-DD format, like 2025-02-15.

Add a date field to a content model

  • Open Slice Machine

    In your Prismic project, start Slice Machine to begin editing content models.

    npx start-slicemachine --open
  • Add a date field

    In Slice Machine, navigate to the slice, page type, or custom type you want to modify. Add a date field.

    The label determines the label shown to content writers in the Page Builder. Use an easily understood name.

    The API ID determines the property name in the Document API. Use a short, snake-cased name.

Use date fields

Date fields can be used anywhere a date is needed. It is often helpful to first convert the date to a JavaScript Date object using asDate from @prismicio/client.

import { asDate } from "@prismicio/client";

function Slice() {
  const date = asDate(slice.primary.release_date);

  return <span>{date?.toLocaleDateString("en-US")}</span>;
}

Tips

API response

Here is what a date field looks like from the Document API:

{
  "example_date": "2030-01-31"
}