Templating the Timestamp field
The Timestamp field allows content writers to add a date and time.
Access the default Timestamp string
Here is an example that shows how to access the Timestamp field value as the default string. In this case the Date field has the API ID of event_date.
const eventTime = document.event_date;
Convert the date to a DateTime object
Here's an example of how to convert the Date string to a DateTime object using the PrismicDOM.date() function. In this case, the Date field has the API ID of event_date.
const PrismicDOM = require('prismic-dom'); const dateObject = PrismicDOM.Date(document.event_date);
Was this article helpful?
Can't find what you're looking for? Get in touch with us on our Community Forum.