Skip to content

Latest commit

 

History

History
74 lines (53 loc) · 1.14 KB

date.mdx

File metadata and controls

74 lines (53 loc) · 1.14 KB

Date

A date picker. Stored as a Y-m-d string.


PHP API

Field::date(string $key): DateField

Type-specific methods

->format(string $format): static

Display format in the picker (PHP date format). Default: 'Y-m-d'.

->minDate(string $date): static

Minimum selectable date ('Y-m-d' or 'today').

->maxDate(string $date): static

Maximum selectable date.

->returnFormat(string $format): static
Format Returns
'' (default) string — '2026-06-01'
'DateTime' \DateTime object or null
'timestamp' int Unix timestamp

Storage

{ "launch_date": "2026-06-01" }

Example

Field::date('launch_date')
    ->label('Launch Date')
    ->format('d/m/Y')
    ->minDate('today')
    ->returnFormat('DateTime'),

Template usage

@php $date = ctrlfield_get('launch_date') @endphp

{{-- With returnFormat('DateTime') --}}
@if($date)
    {{ $date->format('F j, Y') }}    {{-- "June 1, 2026" --}}
@endif

{{-- Raw string (no returnFormat) --}}
{{ ctrlfield_get('launch_date') }}  {{-- "2026-06-01" --}}