1

I want to standarize datetime formats in my lightning app. My requirement is datetime display format based on Salesforce user locale settings. One possible approach that is based on static locale -> datetimeformat mappings implemented in JS code, but in my opinion it isn't very flexible solution. New locales and formats added to Salesforce in future always will need additional mappings in my source code. I want to know what is the best solution?

Grzegorz Połuch
  • 699
  • 9
  • 32

1 Answers1

1

in my experience the ui: components DO NOT respect the users server-side locale but instead showing up in the browsers locale. In chrome this is determined by the language you have chosen (client side browser settings!).

For my taste, it's very bad.

One option could be to use lightning:outputField if you want to show field values.

Another option is just to believe that the browsers locale is set according to the server-side locale (which is mostly true but not guaranteed)

For everything else dynamic formatting with APEX could be an option, howevet it requires extra code and is not nice.

Salesforce should make the browsers local ALWAYS irrelevant and ONLY use the server side locale. Anywhere.

Uwe Heim
  • 28,350
  • 18
  • 115
  • 283