0

I'm using lightning input of type date in my lighting component. Once the date is selected it is showing date as **Feb 12, 2019 ** But we want the date to be shown as MM/DD/YY. is it possible

Here is the code:

<div class="slds-form-element">
                                <div class="slds-form-element__control">
                                    <lightning:input type="date" aura:id="fieldId" label="Start Date of Travel"
                                                     name="startDateOfTravel"
                                                     value="{!v.startDateOfTravel}"
                                                     required="true"/>
                                </div>
                            </div>

een

2
  • 2
    Could you edit your question and add some code to illustrate the problm?
    – Raul
    Commented Feb 11, 2019 at 12:59
  • Added code and screenshot for clarity
    – prasanth
    Commented Feb 11, 2019 at 13:04

1 Answer 1

1

You can use ui:inputDate, you can define your date format in format attribute.

<ui:inputDate aura:id="EndDateField" value="" displayDatePicker="true" format="MM/dd/yyyy"/>
8
  • on validating these using aura:id the program is not responding. could there be any reason.
    – prasanth
    Commented Feb 11, 2019 at 14:03
  • What kind of validation are you doing ?
    – MIX DML
    Commented Feb 12, 2019 at 6:52
  • var allValid = component.find('expdate').reduce(function (validFields, inputCmp) {
    – prasanth
    Commented Feb 12, 2019 at 12:10
  • I'm getting this error
    – prasanth
    Commented Feb 12, 2019 at 12:10
  • This page has an error. You might just need to refresh it. Action failed: c:DateValidation$controller$doAction [inputCmp.showHelpMessageIfInvalid is not a function] Failing descriptor: {c:DateValidation$controller$doAction}
    – prasanth
    Commented Feb 12, 2019 at 12:10

Not the answer you're looking for? Browse other questions tagged .