function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Leticia Monteiro Freitas 4Leticia Monteiro Freitas 4 

Change the date format from input type=date

Hello, I'm trying to use the tag < input type="date" /> but when I use my date is formated like "mm/dd/yyyy".
Can anyone can show how change to: "dd/mm/yyyy"?
Raj VakatiRaj Vakati
Use 
 
<ui:inputDate label="Calendar" format="DD-MM-YYYY" displayDatePicker="true"/>

 
Raj VakatiRaj Vakati
There's not a 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. As Avijit suggests, the current workaround is to use ui:inputDate, but hopefully Salesforce will fix this soo

https://developer.salesforce.com/docs/component-library/bundle/lightning:input/documentation

https://success.salesforce.com/issues_view?id=a1p3A000000FmAgQAK​​​​​​​

 
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
	<ui:inputDate aura:id="EndDateField" value="" displayDatePicker="true" format="MM/dd/yyyy"/>
<ui:inputDate label="Calendar" format="YYYY-MM-DD" displayDatePicker="true"/>
<ui:inputDate label="Calendar1" format="DD-MM-YYYY" displayDatePicker="true"/>


</aura:component>
User-added image​​​​​​​