1

I have an editable date column in a lightning datatable. I need to format dates in that column even for the date picker.

Is there a way to show the string "28 Oct 2020" in the format dd/mm/yyyy such as "28/10/2020"?

enter image description here

2 Answers 2

0

Please try adding below type attributes for date which will show date like mm/dd/yyyy -

{
    label: 'Date Label',
    fieldName: 'dateApiName',
    type: 'date',
    editable: true,
    typeAttributes: {
        year: "numeric",
        month: "2-digit",
        day: "2-digit"
    }
}
1
  • that type attribute formats the final date when the picker is hidden, it does not seem to format the date while date picker is visible which is the requirement we were given.
    – dev4life
    Commented Oct 20, 2020 at 14:48
0

@dev4life, I'm afraid you need to use a custom date picker which will work with a custom data table https://www.lightningdesignsystem.com/components/datepickers/ The date format in LWC datatable is determined by the user locale and there is hardly any control over how we can change the input.

As you see in the screenshot below the input type is of text for the date picker in LWC datatable.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .