0

How do we format the Time in datatable like HH:MM:SS in the LWC data table.

In my datatable column type is defined as Time, expecting the date only format HH:MM:SS.

{ label: "Start Time", fieldName: "Program_Start_Time__c", type: **"time"** },

I went through the LWC data table Documentation:

Displays a date and time based on the locale using lightning-formatted-date-time. Displaying Date and Time Using Type Attributes.

Type Attribute: day, era, hour, hour12, minute, month, second, timeZone, timeZoneName, weekday, year

typeAttributes: {
 day: 'numeric',
month: 'short',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true
}

For displaying only the Time for type=time i have tried the below,

{ label: "Start Time", fieldName: "Program_Start_Time__c", type: "time", typeAttributes: {
**hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true**
} }

Unfortunately not getting the time for the field type Time. Can anyone help with this?

0

I believe this can be got to work by actually setting the type to "date" instead of "time" and using the type attributes you have. Let me know if that works for you.

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.