Skip to content
Viames Marino edited this page Feb 26, 2026 · 2 revisions

Pair framework: Date

Pair\Html\FormControls\Date renders date inputs with formatting and min/max helpers.

Methods

  • dateFormat(string $format): self
  • min(string|DateTime $minValue): self
  • max(string|DateTime $maxValue): self
  • value(string|int|float|DateTime|null $value): static
  • render(): string

Behavior

  • Default format is Y-m-d.
  • If Post::usingCustomDatepicker() and translation key FORM_DATE_FORMAT exists, constructor switches to translated format.
  • min() and max() accept string or DateTime and output Y-m-d when DateTime is used.
  • If Env::get('UTC_DATE') is enabled and value is DateTime, value is converted to user timezone before formatting.

Examples

Native date input with explicit range:

$start = (new \Pair\Html\FormControls\Date('startDate'))
    ->min('2026-01-01')
    ->max('2026-12-31')
    ->value('2026-02-15')
    ->required();

Using DateTime values:

$checkin = (new \Pair\Html\FormControls\Date('checkin'))
    ->value(new DateTime('2026-03-10 14:00:00'))
    ->min(new DateTime('2026-01-01'))
    ->max(new DateTime('2026-12-31'));

Notes

For native <input type="date">, the rendered value should stay browser-compatible (YYYY-MM-DD).

See also: Datetime, Month, Time, FormControl.

Clone this wiki locally