1

I adapted the default date formats to the German needs, and I created a new date format for output. This works fine.

For the input, the Y-m-d format persists. How do I change this? I've created a content type: "events". I defined a field type of DATE:

Field type of date

In the manage form display I've set its witget to "Date and Time. There's no wheel to define dmY or other.

Widget on date field

The result in input mask:

input mask

The only thing that works at the moment, is the widget switching to "date as a list" to get german notation.

1
  • I've updated the answer several hours ago, did you have chance to check if that was working out for you ? Mar 13 '17 at 2:09
2

Assuming the machine name of your content type is "test".

Please navigate to: admin/structure/types/manage/test/form-display

You should see the following form (with different fields, of course).enter image description here

In my example, the name of the field is simply "date" . You can change the widget to Select list and then you will see the cog wheel on the right side of the row.

After clicking on it, you shall be able to choose your preferred Date Format. enter image description here

Hopefully that helps.

Update 1: Regarding Update In my default Drupal installation when I try to add date-based fields, I do have the following 2 options:

  • Date
  • Timestamp

Option Date I have suboptions, "Date only" or "Date and time"enter image description here

  • If I choose "Date and time" -> I am able to see the select widget as option.
  • If I choose "Date only" -> I am able to see the select widget as option.

Timestamp I am able to see only Datetime timestamp enter image description here

As a last thing: Screenshot, showing the different type of fields in Manage form Display: enter image description here

Update 2: It seems the following article has it explained how to do the exact thing you are looking for: https://www.previousnext.com.au/blog/making-drupal-8-datetime-widgets-use-human-formats

9
  • But what about the "Date and Time"? I believe there is no possibility to change its format. It's a pity, because the embedded calendar works fine as it is. Mar 12 '17 at 11:04
  • I am adding a comment, just to update the answer, based on this additional question. Mar 12 '17 at 12:01
  • Please mark the question as accepted if you think It answers your question in detail. Mar 12 '17 at 12:33
  • I've added some images, hope, that's now more understandable. I apologize for any difficulties at my beginning in this forum. Frank Mar 12 '17 at 14:19
  • Hi Frank, This makes it more understandable for me, thank you. They say a picture counts a thousand words, hehe. I understand that for the datepicker widget you would like to change the format. I am not aware what would be the exact code to do that, but for now I am looking at the documentation in core\lib\Drupal\Core\Datetime\Element\Datetime.php #date_date_format, apparently there are some HTML 5 restrictions. I will investigate later more, because this is an interesting issue. Regards Mar 12 '17 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.