Skip to content

date

date<TFieldMeta>(options?): DateField<TFieldMeta>

Defined in: packages/core/src/fields/date/config.ts:58

Creates a date field with all defaults applied.

Date fields store a Unix timestamp in milliseconds. Common uses: published dates, expiry dates, event times, timestamps.

Accepts DateFieldInput (all optional) and returns DateField with all defaults applied.

Defaults applied:

  • label"" (inferred from the field key by defineCollection)
  • requiredfalse
  • time.hiddenfalse (time picker is visible)
  • time.use12HourFormattrue (AM/PM format)
  • time.timePicker.hourtrue
  • time.timePicker.minutetrue
  • time.timePicker.secondfalse
  • admin.hiddenfalse
  • admin.readOnlyfalse
  • admin.position"main"
  • admin.width"full"
  • admin.cellAlignment"left"

TFieldMeta extends BaseFieldMeta = BaseFieldMeta

DateFieldInput<TFieldMeta>

Date field configuration. All properties are optional.

DateField<TFieldMeta>

Resolved date field definition with all defaults applied.

import { date, defineCollection } from '@vexcms/core'
posts: defineCollection({
fields: {
// Minimal — label inferred from key ("Published At")
publishedAt: date(),
// Required event date with a database index
eventDate: date({ required: true, index: "by_event_date" }),
// Date-only picker (hide the time UI)
expiresOn: date({ time: { hidden: true } }),
// Appointment in 24-hour format, shown in the sidebar
appointmentAt: date({
required: true,
time: { use12HourFormat: false },
admin: { position: "sidebar", width: "half" },
}),
}
})