How to Format Date in new grocery crud

hello @johnny

I noticed in the new version of Grocery CRUD that the date format settings have been removed. Is there another way to format dates in tables and input forms after this setting has been removed?

Regards
Nasrul

Hi, I think it’s native_date :wink:

Hello @nasrul ,

Unfortunately the current way is that it uses the browser date formatting. We have removed the hardcoded one since it was causing bugs in different browsers (more specifically Safari on mobile).

What is the issue that you have? Also as @ajuser said, maybe by using native_date will resolve the issue that you have?

In order to do that use fieldType. For example:

$crud->fieldType(‘my_field’, ‘native_date’);

Regards
Johnny

hello @nasrul

$crud->callbackColumn('tanggal_pembelian', function ($value, $row) {
            if (!empty($value)) return convertYmdToDmy($row->tanggal_pembelian);
        });

my helper function ::

if (! function_exists('convertYmdToDmy')) {
    function convertYmdToDmy($date)
    {
        return Carbon::createFromFormat('Y-m-d', $date)->format('d-m-Y');
    }
}

hope this help

regards,
dodo

1 Like