You need to sign in to do that
Don't have an account?

Lightning datatable date field showing one day less when formatted
When using lightning datatable and displaying a date field, its showing a day less than the value in the backend object.
Controller:
component.set('v.Columns',[
{label:'Transport. mode', fieldName:'Mode_of_Transportation__c', type:'text', editable: false,initialWidth:180},
{label:'Ground Company', fieldName:'Ground_Transportation_Company__c', type:'text', editable: false,initialWidth:210},
{label:'Inv./Chg. date', fieldName:'Charge_Invoice_Date__c', initialWidth:150, type:'date', editable: false , typeAttributes:{month:'2-digit',day:'2-digit',year:'numeric'}}
]
Datatable:
<lightning:datatable aura:id="OppExpGTDataTable"
data="{! v.Opp_Expenses_GTXYZ }"
columns="{! v.Columns }"
keyField="Id"
onsave ="{!c.onSave}"
hideCheckboxColumn="true"
onrowaction="{! c.handleRowAction }"/>
Using a custom pop up, we are creating records into database capturing date values. Its getting stored in database properly, when displaying in UI, its showing a day less. In out of the box fields, its showing correctly again. How to format the field in lightning datatable/controller? Appreciate your help..
Controller:
component.set('v.Columns',[
{label:'Transport. mode', fieldName:'Mode_of_Transportation__c', type:'text', editable: false,initialWidth:180},
{label:'Ground Company', fieldName:'Ground_Transportation_Company__c', type:'text', editable: false,initialWidth:210},
{label:'Inv./Chg. date', fieldName:'Charge_Invoice_Date__c', initialWidth:150, type:'date', editable: false , typeAttributes:{month:'2-digit',day:'2-digit',year:'numeric'}}
]
Datatable:
<lightning:datatable aura:id="OppExpGTDataTable"
data="{! v.Opp_Expenses_GTXYZ }"
columns="{! v.Columns }"
keyField="Id"
onsave ="{!c.onSave}"
hideCheckboxColumn="true"
onrowaction="{! c.handleRowAction }"/>
Using a custom pop up, we are creating records into database capturing date values. Its getting stored in database properly, when displaying in UI, its showing a day less. In out of the box fields, its showing correctly again. How to format the field in lightning datatable/controller? Appreciate your help..
If we use type:'date-local' instead of type:'date', its showing correct date. For the benefit of others, here is the link that helped:
https://salesforce.stackexchange.com/questions/221698/help-with-working-with-lightningdatatable/244352#244352
All Answers
If we use type:'date-local' instead of type:'date', its showing correct date. For the benefit of others, here is the link that helped:
https://salesforce.stackexchange.com/questions/221698/help-with-working-with-lightningdatatable/244352#244352
https://mathsolver.pro/mathway/