Date in ColumnControl searchDateTime not formatted correct

Date in ColumnControl searchDateTime not formatted correct

WernfriedWernfried Posts: 20Questions: 5Answers: 0

I have two more issues with ColumnControl

In searchDateTime you say "The format of the date input will match the format used in the column if using the builder in datetime rendering function."

But this is not the case. I am using Luxon and my locale is de-CH. Month and weekday names are written in English.

$("#dataTable").DataTable({
   data: [
      { "ts": "2025-03-01T10:00:00Z", "id": 1 },
      { "ts": "2025-03-02T10:00:00Z", "id": 2 },
      { "ts": "2025-03-03T10:00:00Z", "id": 3 },
      { "ts": "2025-03-04T10:00:00Z", "id": 4 },
   ],
   columns: [
      {
         name: 'ts', data: 'ts', title: 'Start Time', type: 'date',
         columnControl: [
            "order",
            [
               { extend: "searchDateTime", format: 'YYYY-MM-DD', excludeLogic: ['notEmpty', 'empty', 'notEqual', 'less'] },
            ]
         ],
         render: DataTable.render.datetime('DD t', 'de-CH')
      },
      { name: 'id', data: 'id', title: 'ID' }
   ]
});

In Europe Monday is the first day of the week (unlike US where week starts on Sunday), but I guess this is correct just by coincidence.

Life Example: https://live.datatables.net/fuyabozi/1/edit

Of course, this is not a critical issue.

Wernfried

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 65,465Questions: 1Answers: 10,874 Site admin
    Answer ✓

    Month and weekday names are written in English.

    You'll need to set the i18n.datetime parameters to have the date picker strings translated. The French translation is complete if you want to use that as a template.

    In Europe Monday is the first day of the week (unlike US where week starts on Sunday), but I guess this is correct just by coincidence.

    That isn't something that is currently detected automatically. The DateTime library does have an option to set it, but that isn't something that is currently exposed as an option for the searchDateTime input type I'm afraid. At least not yet, that is something I can look at adding.

    Allan

Sign In or Register to comment.