Skip to content

date

date<TCollectionSlug, TFieldKey, TFieldMeta>(options?): DateField<TCollectionSlug, TFieldMeta>

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

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)
  • required — false
  • time.hidden — false (time picker is visible)
  • time.use12HourFormat — true (AM/PM format)
  • time.timePicker.hour — true
  • time.timePicker.minute — true
  • time.timePicker.second — false
  • admin.hidden — false
  • admin.readOnly — false
  • admin.position — "main"
  • admin.width — "100%"
  • admin.cellAlignment — "left"

TCollectionSlug extends string = string

TFieldKey extends string = never

TFieldMeta extends BaseFieldMeta = BaseFieldMeta

DateFieldInput<TCollectionSlug, TFieldKey, TFieldMeta>

Date field configuration. All properties are optional.

DateField<TCollectionSlug, 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: "50%" },
}),
}
})