0

I need help from experts for a lightning data table with 'Date' type field. I want to strictly set it's timezone to 'Australia/Melbourne' irrespective of user's local timezone. For example, Even if an user from India is checking the record, the 'Date' field should display data in 'Australia/Melbourne' timezone only.

I am using the below code, but it is not working :

const columns = [ { fieldName: "Date", hideDefaultActions: true, label: "DATE", type: "Date", sortable: "true", typeAttributes: { timezone: 'Australia/Melbourne' } } ]

Let me know if any further inputs needed from my end. Thanks!

1 Answer 1

1

I think this is a quickfix. Try using the timeZoneName attribute instead.

date Displays a date and time based on the locale using lightning-formatted-date-time. See Displaying Date and Time Using Type Attributes. day, era, hour, hour12, minute, month, second, timeZone, timeZoneName, weekday, year

See the official documentation for further details.

2
  • using the timeZoneName instead of timeZone, producing the same result : { fieldName: "Date", hideDefaultActions: true, label: "DATE", type: "Date-local", sortable: "true", typeAttributes: { timeZoneName: 'Australia/Melbourne' } }, Sep 24, 2020 at 7:46
  • I think you're using the date local value when you should be using the date value. It uses the lightning-formatted-date-time component so you have to follow the spec for this component. Just to be explicit here it is straight from the docs: date-local Displays a date that is formatted based on the locale using lightning-formatted-date-time. To include a time value, use the date type instead. The value passed is assumed to be in the browser local time zone and there is no time zone transformation. See Displaying Date and Time Using Type Attributes. Sep 24, 2020 at 7:50

You must log in to answer this question.

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