Timestamp Templating

The Timestamp field allows content writers to add a date and time.

Default Format

Here’s an example of how to integrate a Timestamp field into your template.

  • ejs
  • pug
  • pug (API v1)
Copy
<span class="event-date">
  <%= PrismicDOM.Date(document.data.eventDate) %>
</span>
Copy
span.event-date !{ PrismicDOM.Date(document.data.eventDate) }
Copy
span.event-date !{ document.getTimestamp('event.date').toString() }

Custom Format

You can change the format timestamps are displayed by using DateTimeFormat and adjusting the parameters to your needs.

  • ejs
  • pug
  • pug (API v1)
Copy
<span class="event-date">
  <%= Intl.DateTimeFormat('en-US',{ year: 'numeric', month: 'short', day:'2-digit', hour:'numeric', minute: '2-digit', second: '2-digit' }).format(PrismicDOM.Date(document.data.eventDate)) %>
</span>
Copy
span.date
  = Intl.DateTimeFormat('en-US',{ year: 'numeric', month: 'short', day: '2-digit', hour:'numeric', minute: '2-digit', second: '2-digit' }).format(PrismicDOM.Date(document.data.eventDate))
Copy
span.date
  = Intl.DateTimeFormat('en-US',{ year: 'numeric', month: 'short', day: '2-digit', hour:'numeric', minute: '2-digit', second: '2-digit' }).format(document.getDate('post.eventDate'))