As far as I know there is no such thing as a locale aware date formatter built into c8y web sdk.
But since it depends on moment.js it should not be too complicated to write your own date formatter pipe.
import { Pipe, PipeTransform } from '@angular/core';
import { MomentInput } from 'moment';
import { TranslateService as NgxTranslateService } from '@ngx-translate/core';
import * as moment from 'moment';
@Pipe({ name: 'customdateformatter' })
export class MomentFormatPipe implements PipeTransform {
constructor(private translateService: NgxTranslateService) {}
transform(value: MomentInput, formatPattern: string): string {
if (!value) {
return '';
}
return moment(value)
.locale(this.translateService.currentLang)
.format(formatPattern);
}
}
If you do not want to specify a custom date format pattern you can always use one of the default ones moment.js provides.
moment().format('LT');
moment().format('LTS');
moment().format('L');
moment().format('l');
moment().format('LL');
moment().format('ll');
moment().format('LLL');
moment().format('lll');
moment().format('LLLL');
moment().format('llll');