Open DinhHien0307 opened 3 years ago
This looks great. Are you editing the same date element or created a new one?
Hi @mdjnelson, I am editing the existing date element, I only create a new setting, which you can edit the date format when adding a new date element.
Are you creating a PR for this anytime soon?
Hi @mdjnelson I have created a PR for this, please take a look at it.
Hi @mdjnelson I would like to add a new feature for an additional date format. The main idea is to add a new setting as a multi-line text field and the default is 2 options using in the code (hard code).
We don't need to add validation to check invalid or duplicated formats. While we may add a link to the description for introduction and the link should be https://www.php.net/manual/en/datetime.format.php for help.
Need to add a character in the database before the formatted text (so it can easily be distinguished as a custom format), like '=%d %m %y', We will change the current logic to save to the database, instead of index 1 or 2 of the custom option, it should be stored as the value got from the admin setting example: '%d %m %y'.
We will a new special symbol '#' to present for 1st, 2nd, 3rd as handling by this function get_ordinal_number_suffix, and should add an intro for this symbol in the description too.
Description I suggest for the setting:
Custom date formats are available for selection when adding a certificate, listed one per line. Example: %d %m %y. (See PHP documentation.) In addition, the special symbol # can be used to indicate 'st', 'nd', 'rd' or 'th', for 1st 2nd 3rd 4th of the month. Changing this list does not affect existing certificates, only the options available when creating or updating a certificate.
Make an upgraded database to convert items are using index=1 to '%B %d, %Y' and index = 2 to '%B %d#' same as defined in the code.
Existing data for index 1 and 2 will display correctly after upgraded database (other indexes have to display the same too)
I will submit a pull request for this. Please ask if you have any question
This is the demo: