Presenter Output
This section will show you how to use the decorated value provided by the \Anomaly\DatetimeFieldType\DatetimeFieldTypePresenter
class.
DatetimeFieldTypePresenter::format()
The format
method maps to the Carbon::format()
method.
Returns: string
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$format |
false |
string |
The configured format. |
A PHP date format. |
Example
$decorated->example->format();
Twig
{{ decorated.example.format() }}
DatetimeFieldTypePresenter::date()
The date
method returns the formatted date portion of the value only.
Returns: string
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$format |
false |
string |
The configured value. |
A PHP date format. |
Example
$decorated->example->date();
Twig
{{ decorated.example.date() }}
DatetimeFieldTypePresenter::time()
The time
method returns the formatted time portion of the value only.
Returns: string
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$format |
false |
string |
The configured value. |
A PHP date format. |
Example
$decorated->example->time();
Twig
{{ decorated.example.time() }}
DatetimeFieldTypePresenter::local()
The local
method returns the formatted value in the users active timezone.
Returns: string
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$format |
false |
string |
The configured format. |
A PHP date format. |
Example
$decorated->example->local();
Twig
{{ decorated.example.local() }}
DatetimeFieldTypePresenter::timeAgo()
The timeAgo
ago method maps to Carbon::diffForHumans()
.
Returns: string
Example
$decorated->example->timeAgo();
Twig
{{ decorated.example.timeAgo() }}
DatetimeFieldTypePresenter::iso()
The iso
method is a shortcut for returning the ISO 8601 formatted value.
Returns: string
Example
$decorated->example->iso();
Twig
{{ decorated.example.iso() }}
DatetimeFieldTypePresenter::rfc()
The rfc
method is a shortcut for returning the RFC 2822 formatted value.
Returns: string
Example
$decorated->example->rfc();
Twig
{{ decorated.example.rfc() }}
DatetimeFieldTypePresenter::__call()
The __call
magic method is mapped to Carbon
.
Example
$decorated->example->toDayDateTimeString();
Twig
{{ decorated.example.toDayDateTimeString() }}