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

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.

| improve this answer | |
  • 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' } }, – Gaurav Sharma Sep 24 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. – Luigi Campbell Sep 24 at 7:50

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.