Add option for custom date time format

Created on 18 February 2019, almost 6 years ago
Updated 10 September 2024, 4 months ago

It would be nice to have an option to choose the output format of the displayed date field. As there is no way for this currently (this part is hard-coded), I added a small change to the module. It is however available only programatically by now.
If applied, one would be able to add an option '#custom_format' => 'd-m-Y H:i' for example(or any other supported format) and the date would be displayed as desired.

Feature request
Status

RTBC

Version

2.0

Component

Code

Created by

🇧🇬Bulgaria tzandev Sofia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇱Netherlands spadxiii

    Found another bug where it would still validate when leaving the end-date empty.

    ps. an interdiff doesn't seem to generate : interdiff: Whitespace damage detected in input

  • 🇳🇱Netherlands spadxiii

    Found another small issue where it would strip the time from the entered values. And the end-value wasn't handled correctly.

    Here's a new patch.

  • Status changed to RTBC almost 2 years ago
  • 🇳🇱Netherlands idebr

    The new option to configure a custom format per field widget works as expected, thanks!

  • 🇵🇹Portugal jcnventura

    @idebr, Thanks for the review. Why did you hide the patch from #23 and #16. Are you saying the one you tested is the last one not hidden (#14) ?

    Please clarify and hide all files other than the one you tested, please..

  • 🇳🇱Netherlands idebr

    I was unaware I changed the displayed patches. I tested the latest patch in #23.

  • First commit to issue fork.
  • Status changed to Needs review almost 2 years ago
  • 🇳🇱Netherlands idebr

    Attached patch implements the following changes:

    1. Applied default value formatting to single_date_time_timestamp_widget and single_date_time_widget
    2. Applied massageFormValues() to all widgets that extend SingleDateTimeBase
  • Status changed to RTBC almost 2 years ago
  • 🇳🇱Netherlands anneke_vde

    I tested patch #28, looks good the default_value formatting is now correct.

  • 🇧🇪Belgium chewi3

    Rerolled the latest patch for 2.0.0-beta2.

  • 🇳🇱Netherlands watergate

    I can confirm that this works correctly. Thanks for the patch.

  • 🇧🇬Bulgaria shaxa

    Unfortunately, patch number 30 doesn't work for me. There is one small mistake which causes on each save to delete the date from the fields. I have changed $element['value']['#custom_format'] ?? $format to $element['value']['#custom_format'] ?: $format as the #custom_format is actually empty string by default.

Production build 0.71.5 2024