I am struggling to convert a timestamp to the date format 'dd/MM/YYYY' but keep getting a different date format in the output. I am using syncfusion spreadsheet for this task.
https://i.sstatic.net/BoRaa.png
export-electronic.component.ts
updatedata(){
this.dataApi.getElectronicById(this.id).subscribe(res => {
this.electronicObj = res;
console.log(this.electronicObj);
this.spreadsheetObj.updateCell({ value:
this.electronicObj.mantainence_history},"O3");
this.spreadsheetObj.updateCell({ value:
this.electronicObj.cost_status},"P3");
this.spreadsheetObj.updateCell({ value: this.electronicObj.warranty_date.toDate()+this.electronicObj.expire_date.toDate()},"Q3");}
export-electronic.component.html
<ejs-spreadsheet #spreadsheet (created)="created()" (openComplete)="updatedata()" openUrl='https://ej2services.syncfusion.com/production/web-services/api/spreadsheet/open' allowOpen='true' (beforeSave)='beforeSave($event)' saveUrl='https://ej2services.syncfusion.com/production/web-services/api/spreadsheet/save' allowSave='true'>
</ejs-spreadsheet>
When displaying the result in an excel cell, I need it to appear like this: Example 29/11/2022 - 01/12/2022 Thank you for any guidance provided.
**** The Answer *****
updatedata(){
this.dataApi.getElectronicById(this.id).subscribe(res => {
this.electronicObj = res;
console.log(this.electronicObj);
const q3Value = (new Date(this.electronicObj.warranty_date.toDate()).toLocaleDateString('en-GB')) + ' - ' + (new Date(this.electronicObj.expire_date.toDate()).toLocaleDateString('en-GB'));
this.spreadsheetObj.updateCell({ value:
this.electronicObj.mantainence_history},"O3");
this.spreadsheetObj.updateCell({ value:
this.electronicObj.cost_status},"P3");
this.spreadsheetObj.updateCell({ value: q3Value},"Q3");
});
}