The date format of a column in a datagrid is correct on the screen dd-mm-yyyy.
But if I try to print that datagrid from the GroceryCrud print button, the output format changes to yyyy-mm-dd.
I have tried:
$crud->fieldTypeColumn(‘DOB’, ‘native_date’);
$crud->fieldType(‘DOB’, ‘native_date’);
But nothing seems to fix the issue.
Any suggestions?
It seems that this is a bug and I can reproduce it as well. I will try to have it fixed for the newer version. If I see that the new release is taking longer (preparing 3.3 which is a bigger one) I will try to suggest you a work-around for this.
These run in PHP instead of the browser, so they apply the same way to both the datagrid and the print output, and the mismatch goes away.
Why it’s tricky: the datagrid gets its date format from the browser’s locale, which usually just works. But the print/PDF/Excel output is generated server-side, and PHP has no way to know what format the browser used. A real fix means bringing back a date_format-style setting that was removed in v3.
I’ve been looking into this, and I might get it into an upcoming version — no promises yet, since it’s a bigger change. Hoping for 3.3.0, though 3.3.1 is more likely, since 3.3.0 is already delayed by a large frontend refactor that I am working now.
Thanks for the fast response.
The workaround works well.
Now the print format is the same as the display format.
And the sorting of those date columns still works.
The only hiccup is the quick search function throws an error. I think because a string is being search for in the database column that holds dates.
This for me is not a big issue, but for the release solution, the search function should work.
Thanks again
Hello @mopac , I can’t reproduce the issue that you are referring to. What database are you using ? A quick solution into that is to use the function fieldTypeSearchColumn for example in your case this can be: