How to change the date fomat using Lightning:input type=“date” ?

1.9K    Asked by Aashishchaursiya in Salesforce , Asked on Jul 12, 2021

 I'm trying to change date format of this component but I dont find any attribute (like ui:inputDate has) to change the date format.

NOTE:Also I have used the new for dates and actually works really nice but date format is a must I need to change.

This is an example of official lightning input here: LightningInput docs

The first one is Lightning input, the second one is ui:inputDate component.

I'm guessing it is changed by your Time Zone but actually, there is no change at all. enter image description here

Any ideas about how can I use it with the date format I want (DD/MM/YYYY)? Thanks

 

Answered by Amit verma

There's no way to specify the date format for date or datetime input fields lightning:input / lightning:inputField. This is meant to be controlled by the user's locale per the component library docs "The date and time formats are automatically validated against the user’s Salesforce locale format during the onblur event". The formats you should expect to see for each locale are documented here: Supported Locales. The incorrect format you are seeing is due to this known issue: Lightning:input $Locale date/time formats are inconsistent with the docs. It need to be done with ui:input  formatting lightning input is not available. type="datetime-local" is not working seems a bug at salesforce or not yet implemented yet



Your Answer

Interviews

Parent Categories