The year is displayed wrong while using Date pipe and moment.js (Angular 13)

148 Views Asked by At

I'm using Moment.js to convert my date , but it displayed a wrong year

below a part of my code in localized-moment.ts file :

transform(value: any, pattern: string = 'short'): any {

if (value.toString().includes('-')) {

  return moment(value).locale(this.translateService.currentLang).format('L LTS');

} else {

  if (!Number.isInteger(value)) {

    value = moment.unix(value);

  }
  
  return moment(value).locale(this.translateService.currentLang).format('L LTS');

}

}

then in my html , i'm using the pipe to convert :

        <td class="data-row">{{myTime | localizedMoment }}</td>

For example if value=1672828478537 after the call of pipe , I m getting 06/01/2023 12:12:36 instead of 06/01/2022 12:12:36

Thanks for your help in advance .

0

There are 0 best solutions below