Overview
TheDateColumn displays date and datetime values with automatic formatting. It handles DateTime objects, Carbon instances, and string dates, formatting them according to your specified format string.
Creating a Date Column
Basic Usage
Factory Method
You can also create date columns using the baseColumn class:
Date-Specific Methods
Specify the date format. Accepts either a PHP date format string or a closure for custom formatting logic.Default format:
'Y-m-d'Common Methods
Date columns support all common column methods:Set a custom label for the column header.
Enable sorting on this column.
Enable searching on this column.
Completely customize the cell content. This takes precedence over
format().Set the column width.
Apply CSS classes to both header and cells.
Apply CSS classes only to the column header.
Apply CSS classes only to the column cells.
Hide the column from display.
Conditionally hide the column.
Examples
Basic Date Column
Date with Time
Relative Time (Human Readable)
ISO 8601 Format
Short Date Format
Null-Safe Date with Fallback
Conditional Date Formatting
Multiple Date Columns
Date with Timezone
Day of Week Display
Compact Date Display
Date Format Reference
Common PHP date format characters:| Format | Description | Example |
|---|---|---|
Y | 4-digit year | 2024 |
y | 2-digit year | 24 |
m | Month (01-12) | 12 |
n | Month (1-12) | 12 |
M | Short month name | Dec |
F | Full month name | December |
d | Day (01-31) | 05 |
j | Day (1-31) | 5 |
l | Full day name | Monday |
D | Short day name | Mon |
H | 24-hour (00-23) | 15 |
h | 12-hour (01-12) | 03 |
i | Minutes (00-59) | 45 |
s | Seconds (00-59) | 30 |
A | AM/PM | PM |
a | am/pm | pm |
T | Timezone | UTC, EST |
c | ISO 8601 | 2024-12-05T15:45:00+00:00 |
Resolution
TheDateColumn resolution handles multiple input types:
DateTimeorDateTimeInterfaceinstances (including Carbon)- String dates (parsed with
strtotime()) null(returnsnull)
Type
The column type identifier forDateColumn is 'date'.