Timestamp
This article explains what the timestamp field is and how to configure it.
The timestamp field allows content writers to select a date and time.
The timestamp is saved in YYYY-MM-DDTHH:MM:SS+0000
format, like 2025-02-15T01:53:50+0000
. The timestamp is always UTC (+0
offset).
Add a timestamp 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 timestamp field
In Slice Machine, navigate to the slice, page type, or custom type you want to modify. Add a timestamp 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 timestamp fields
Timestamp fields can be used anywhere a timestamp is needed. It is often helpful to first convert the timestamp to a JavaScript Date
object using asDate
from @prismicio/client
.
import { asDate } from "@prismicio/client";
function Slice() {
const timestamp = asDate(slice.primary.release_timestamp);
return <span>{timestamp?.toLocaleDateString("en-US")}</span>;
}
Tips
Use
isFilled.timestamp()
to check if a timestamp field has a valueimport { isFilled } from "@prismicio/client"; if (isFilled.timestamp(slice.primary.my_timestamp_field)) { // Do something if `my_timestamp_field` has a value. }
API response
Here is what a timestamp field looks like from the Document API:
{
"example_timestamp": "2030-01-31:05:00:00+0000"
}