I'm creating a LWC with datatable that shows some of the key record values. I have just one issue - regarding the date/time formatting.
For some reason, the field is shown as:
My goal is to show it as follow:
I tried everything, but nothing seems to help here .. This is my code:
HTML
<template>
<lightning-card>
<lightning-datatable class="slds-table_header-fixed_container slds-scrollable_x slds-border_top"
data={data}
columns={columns}
key-field="id"
hide-checkbox-column="true"
show-row-number-column="true">
</lightning-datatable>
</lightning-card>
</template>
JS
import { LightningElement } from 'lwc';
const columns = [
{label: 'Created Date',
fieldName: 'CreatedDate',
sortable: "true",
type: "date",
typeAttributes:{
hour: "2-digit",
minute: "2-digit",
day: "2-digit",
month: "2-digit",
year: "numeric"}}];
export default class FormattedDateTimeDateTime extends LightningElement {
columns = columns;
data = [{"CreatedDate":"2021-05-17T14:04:23.000Z"}];
}
Any help will be appreciated. Thanks !