Unlock seamless workflows and faster delivery with our latest releases – get the details

Content Model for Storing Time Data - e.g. Opening Times

2 replies
Last updated: Apr 8, 2020
Can anyone help me with the best way to store a time only? Like if I wanted to have a page listing store hours...something like:Mon - Thurs: 8
:00am-8:00pmFri - Sat: 8
:00am-10:00pmSun: 8
:00am-6:00pm
What does that content model look like?
Apr 8, 2020, 12:26 PM
Hi ! There is several options for this.Maybe as simple as a "text" field with free text content inside or as granular as :
An array field of open days object.
Each Open days object is an array of opening hours object
And each opening hours object a combination of two fields : a start time and a end time (could be text fields, or maybe datetime, or custom time input).

This way each day could have several opening hours allowing for a mid-day break.
Apr 8, 2020, 12:36 PM
Thanks! This is very helpful. I also found a guide that goes through how to create a custom input component for this exact use case: https://www.sanity.io/guides/how-to-make-a-custom-input-component
Apr 8, 2020, 12:52 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?