0

How to change the Date format as DD-MM-YYYY in lightning data table ?

The Result is 1936-06-12

I Want the result as 12-06-1936

Please help....

code snippet

{label: 'Contact Name', fieldName: 'Name', type: 'text',sortable:true},
{label: 'Birthdate', fieldName: 'Birthdate', type: 'Date',sortable: true,typeAttributes{day:'numeric',month:'short',year:'numeric'}}, {label: 'Email', fieldName: 'Email', type: 'email',sortable:true}

Thanks in Advance.

2 Answers 2

1

The "type" attribute is case-sensitive, as are most things in Lightning. "Date" is an unrecognized value, so it defaults to text, while "date" is a recognized value that formats a value as a date. When reading any documentation regarding Lightning, assume that whatever is in the documentation is a case-sensitive value and must be precisely the right case or you'll get unexpected results.

Sign up to request clarification or add additional context in comments.

Comments

0

See "Displaying Date and Time Using Type Attributes" on this page: https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation

I think you'll want to change your type attributes to this:

typeAttributes:{
    month: "2-digit",
    day: "2-digit",
    year: "numeric"
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.