Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
simonfairway

inline editing of dates changes stored date format

I’ve got a custom field storing dates in the format YYYY-MM-DD. When I defined a column for it, choosing the output format works. However, when I inline edit a date, it then gets stored in the format YYYYMMDD.

I can’t even track down in the code where this is happening – any ideas?

6 years, 1 month ago
Stefan van den Dungen Gronovius
Developer

Hello,

Thanks for your feedback. I/we agree that the used format is not ideal as a default to store dates and this is something we want to change in the future. We’re thinking of a column setting for editing where you can manually set the storage date format. Or maybe just change the format, but that would require some fallbacks for the older date formats.

The code where this logic is happening is
/classes/Editing/Model/CustomField/Date.php

But you might want to have a look at this specific hook.
https://www.admincolumns.com/documentation/filter-reference/acp-editing-save/

The hook is fired after the value is already stored by our plugin. But you can do another save action and store the value to the DB the way you like. You have the actual value at your disposal, including the $column object that you can use to do some conditionals, like checking for the custom field and doing a field type check.

6 years, 1 month ago
Dirk

+1 for setting the date format. At a minimum, changing to YYYY-MM-DD would allow the feature to be usable.

5 years, 11 months ago
Stefan van den Dungen Gronovius
Developer

Hi Dirk,

I totally agree on your last comment.
But only change the default would break a lot of installs that already with the old Ymd format.
So the default format has to be together with the new date format setting.

5 years, 11 months ago
Stefan van den Dungen Gronovius
Developer

Thanks for pointing us to the out of date documentation.
I just updated the documentation.

5 years, 10 months ago
info313

I believe I am having the same issue, if I edit the date in the listing (using theme Listify) itself, it is properly formatted the way I want it (i.e. September 26, 2018). However, if I use the the inline date editor, the format is outputted as 20180926. The above solution does not help that much as I need step-by-step instructions, if that is indeed the solution to this this very “customer sensitive” issue. Can you help me with that please? It would be very appreciated.

5 years, 6 months ago

You must be logged in to reply to this topic.