Fields

Date

Extends Text

  • has the same features

The Date field is an extension of Text, which by default sets type=date and has additional methods.

use MoonShine\Fields\Date;
 
//...
 
public function fields(): array
{
return [
Date::make('Created at', 'created_at')
];
}
 
//

Creation date Creation date

Date and time

Using the withTime() method allows you to enter a date and time into a field.

withTime()
use MoonShine\Fields\Date;
 
//...
 
public function fields(): array
{
return [
Date::make('Created at', 'created_at')
->withTime()
];
}
 
//...

date_time

date_time_dark

Format

The format() method allows you to change the display format of the field value in preview.

format(string $format)
use MoonShine\Fields\Date;
 
//...
 
public function fields(): array
{
return [
Date::make('Created at', 'created_at')
->format('d.m.Y')
];
}
 
//...