Templating the Date field
The Date field allows content writers to add a date that represents a calendar day.
Access the default date string
Here is an example that shows how to access the Date field value as the default string. In this case the Date field has the API ID of event_date.
const dateString = 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.