Open swuecho opened 8 months ago
// CustomTimestampRendererComponent.ts import { Component } from '@angular/core'; import { ICellRendererAngularComp } from '@ag-grid-community/angular'; @Component({ selector: 'app-custom-timestamp-renderer', template: ` <div [title]="formattedTimestamp">{{ formattedTimestamp }}</div> `, }) export class CustomTimestampRendererComponent implements ICellRendererAngularComp { params: any; formattedTimestamp: string; agInit(params: any): void { this.params = params; this.formatTimestamp(); } refresh(params: any): boolean { this.params = params; this.formatTimestamp(); return true; } private formatTimestamp(): void { const timestamp = this.params.value; const timezone = this.params.data.timezone; // Assuming the data has a 'timezone' property if (timestamp && timezone) { this.formattedTimestamp = moment(timestamp).tz(timezone).format('YYYY-MM-DD HH:mm:ss'); } else { this.formattedTimestamp = ''; } } }