You need to sign in to do that
Don't have an account?
![sheila srivatsav sheila srivatsav](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
remove time from datetime in lightning
I have a json coming from api and it has a datetime as 2019-01-01T00:00:00-05:00 I am displaying this in lightning component as below .
<lightning:formattedDateTime value="{!medicareValues.effectivePeriod.datetimeBegin}" year="numeric" month="numeric" day="numeric"/
But I want to remove the time and display the date as 2019-01-01. Please let me know how I can achieve this.
thanks
sheila
<lightning:formattedDateTime value="{!medicareValues.effectivePeriod.datetimeBegin}" year="numeric" month="numeric" day="numeric"/
But I want to remove the time and display the date as 2019-01-01. Please let me know how I can achieve this.
thanks
sheila
Refer this link
https://www.sfdcstuff.com/2017/12/formatting-and-localizing-dates-in.html
https://www.biswajeetsamal.com/blog/salesforce-lightning-formatted-datetime/
https://saramorgan.net/2017/10/01/workaround-for-problem-with-lightninginput-and-datetime-local/
https://salesforce.stackexchange.com/questions/216032/lightningformatteddatetime-changes-the-date/225938
https://developer.salesforce.com/docs/component-library/bundle/lightning:formattedDateTime/documentation
In case if it is possible, ask your API team to send the format which you need.
If you want to fix it from salesforce side use <lightning:formattedDateTime value="2019-12-02T00:00:00-05:00" year="numeric" month="numeric" day="numeric"/> stamp your json field value to this field
it will give output as 12/2/2019
or
in the controller, you can use the substring function of javascript to get first 10 characters.
Naveen