Open navClose nav

Date Field

A date and time picker.

Options

https://res.cloudinary.com/forestry-demo/image/fetch/c_limit,dpr_auto,f_auto,q_80,w_640/https://forestry.io/uploads/2018/05/date-field-ui.png

  • Label – the human-friendly label shown above the input field in the editor.
  • Name – the key stored in your content’s front matter, used to access it in your templates.
  • Description – a human friendly description of what the field does and/or instructions for your editors.
  • Hidden – hides the field in the editor, but allows developers to set default values or maintain the field for legacy purposes.
  • Date Format – how the date should be displayed in the editor.
  • Time Format – how the time should be displayed in the editor.
  • Display UTC – activating this option will display the date in UTC regardless of user’s locale settings.
  • Required – prevent changes from being saved if this field is empty.

Field UI

https://res.cloudinary.com/forestry-demo/image/fetch/c_limit,dpr_auto,f_auto,q_80,w_640/https://forestry.io/uploads/2018/01/datetime-preview.png

Templating

If you have a text field in your template, you can access it in your templates using the field’s name:

Hugo

<time datetime="{{ .Date }}">{{ .Date.Format "January 2, 2006" }}</time>

Jekyll

<time datetime="{{ page.date }}">{{ page.date | date: "%B, %-d, %Y" }}</time>

Config Files

You can configure this field in Front Matter Template Config Files as follows:

type: datetime
name: [String]
label: [String]
description: [String] 
default: [String]
hidden: [true|false]
config:
  date_format: [String]
  time_format: [String]
  display_utc: [true|false]

Example

type: datetime
name: date
label: Date
description: The creation date for this page 
hidden: false
config:
  date_format: "YYYY/MM/DD"
  time_format: "HH:MM:SS"
  display_utc: false

The date_format and time_format fields can be configured using Moment.js tokens.


Last updated on December 31, 2017