0

In my custom LWC component, I out put a date-type field using lightning-output-field tag, and it is formatted by default 'YYYY-MM-DD',

is it possible to show 'YYYY/MM/DD' using lightning-output-field and lightning-input-field?

Or I have to use lightning-input tag?

2

lightning-output-field and lightning-input-field respect running users' locale.

from documentation

...if field-name references a date and time value, then the default output value contains the date and time in the user's locale.

That means, that you can control it by changing the user's locale. So for users with different locals, this field will be displayed in different formats.

If you want to have some static format of date, you'll need to use lightning-input and to set desired date format.

1
  • perfect, thank you.
    – Lanjinest
    Feb 19 at 3:16

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.