laravel-admin icon indicating copy to clipboard operation
laravel-admin copied to clipboard

Date format, not format actully

Open eddjimlab opened this issue 3 years ago • 4 comments

  • Laravel Version: 8.74.0
  • PHP Version: PHP/8.0.12
  • Laravel-admin: 1.8.14

Description:

try use date('format') $grid->column('created_at')->date('Y-m-d'); result 2021-12-01T20:21:43.000000Z

Steps To Reproduce:

eddjimlab avatar Dec 01 '21 21:12 eddjimlab

I've met a similar issue in my environment. Same laravel, PHP and laravel-admin version. What I observe is that when the date is clicked, a datetime picker pops up instead.

ajoluvya avatar Dec 20 '21 13:12 ajoluvya

use DateTimeInterface;

protected function serializeDate(DateTimeInterface $date)
{
    return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
}

Add this method in your model class.

jxlwqq avatar Dec 20 '21 13:12 jxlwqq

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 02 '22 23:03 stale[bot]

Could you please update the documentation accordingly? According to https://laravel-admin.org/docs/en/model-grid-column-display#Date%20format, calling date($format) directly on the column() should set the display format to the given parameter...

anxgstadler avatar Mar 28 '22 09:03 anxgstadler