Date Fields

THIS PAGE
In the graph
In the CMS
In the API

Date type fields are, like the name suggests, useful for storing dates. Additional validations can be added to make it conform to particular range of dates.

In the graph

Screenshot

Create a date field by simply creating a new field and marking the input type as Date.

Additional Properties

Property Description Possible Values
Default Value The default value for this field when no value is provided. Any Date
Required Whether the value is a required field. Can be set in the Validations section

Validations

The date field supports validations only on the date value

Operate On Possible Conditions Possible Values
Date > , >= ,= ,<= ,< Any Date

Multiple validations can be chained together with AND operations

See Field Validations for more information on how to add validations.

In the CMS

Screenshot

When you publish a date field, it's available in the Content Management System as a simple date input. The user can enter any arbitrary date matching the validations set in the graph.

In the API

In the API the output response for this field is a date (unix timestamp).

Sample GraphQL Request

{
  movies {
    title
    releaseDate # Marked as a date field
  }
}

Sample GraphQL Response

{
  "data": {
    "movies": [
      {
        "title": "Superman vs. Spiderman",
        "date": 1283791647817
        // a date timestamp that can be easily
        // converted to a Date object for manipulation
      }
    ]
  }
}
Did you find what you were looking for?
👍
👎
What went wrong?
Need more help?We have a thriving Discordcommunity that can help you with all things Canonic. →