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
sheila srivatsavsheila srivatsav 

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.

Raj VakatiRaj Vakati
You need to use the locationzarionService of Aura framework ..

Refer this link
<lightning:formattedDateTime value="1547250828000" year="numeric" month="numeric" day="numeric"  hour="2-digit" minute="2-digit" timeZoneName="short" />

Naveen KNNaveen KN
Hi Sheila,

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

in the controller, you can use the substring function of javascript to get first 10 characters.