You need to sign in to do that
Don't have an account?
Shatrughna Salunke
Date format in lightning controller
Hi below is my code and l'am looking for chnage the date format
JS Controller
var previouslySearchedDate=[];
var temp = getList; // here we are getting list of record
for(var i=0 ; i<temp.length;i++)
{
if(!$A.util.isUndefinedOrNull(temp[i].previouslySearched))
{
var previousDate=(temp[i].previouslySearched=== undefined ? "" : temp[i].previouslySearched+'');
temp[i].previouslySearchedDate=previousDate;
}
}
CMP
<div class="assoc-label slds-grid slds-wrap">Previously searched on: {!r.previouslySearchedDate}
Current output:
12/1/2000:T0000 ,11/10/2012:T0000
Now , I'm looking as below
12/1/2000,11/10/2012
JS Controller
var previouslySearchedDate=[];
var temp = getList; // here we are getting list of record
for(var i=0 ; i<temp.length;i++)
{
if(!$A.util.isUndefinedOrNull(temp[i].previouslySearched))
{
var previousDate=(temp[i].previouslySearched=== undefined ? "" : temp[i].previouslySearched+'');
temp[i].previouslySearchedDate=previousDate;
}
}
CMP
<div class="assoc-label slds-grid slds-wrap">Previously searched on: {!r.previouslySearchedDate}
Current output:
12/1/2000:T0000 ,11/10/2012:T0000
Now , I'm looking as below
12/1/2000,11/10/2012
https://developer.salesforce.com/docs/component-library/bundle/lightning:formattedDateTime/example
Try the code snippet here (https://www.biswajeetsamal.com/blog/tag/date-format/).
For your reference, you can check this too (https://salesforce.stackexchange.com/questions/143107/date-formatting-to-dd-mm-yyyy).
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.